From efba5b122052a8f3611b6f43e67d0bafdf9148d8 Mon Sep 17 00:00:00 2001 From: Robert Estelle Date: Sun, 3 May 2020 12:52:32 -0700 Subject: [PATCH] Avoid warning under setopt warn_nested_var MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously in a shell running with `setopt warn_nested_var`, the following warning would be produced: > ``` > _zsh_highlight_main__precmd_hook:1: array parameter _zsh_highlight_main__command_type_cache set in enclosing scope in function _zsh_highlight_main__precmd_hook > ``` The documentation for `WARN_NESTED_VAR` is: > Print a warning message when an existing parameter from an enclosing > function scope, or global, is set in a function by an assignment or in > math context. […] Where possible, use of `typeset -g` to set the parame- > ter suppresses the error, but note that this needs to be used every time > the parameter is set. --- highlighters/main/main-highlighter.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index 7ebc971..f0e32de 100644 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -1677,7 +1677,7 @@ _zsh_highlight_main_highlighter_expand_path() # ------------------------------------------------------------------------------------------------- _zsh_highlight_main__precmd_hook() { - _zsh_highlight_main__command_type_cache=() + typeset -gA _zsh_highlight_main__command_type_cache=() } autoload -Uz add-zsh-hook