-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
While sourcing zsh-syntax-highlighting.zsh
, zsh encounter couple of warnings.
/usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh:434: array parameter ZSH_HIGHLIGHT_HIGHLIGHTERS set in enclosing scope in function (anon)
_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
I have my WARN_CREATE_GLOBAL
and WARN_NESTED_VAR
zsh options turned on.
Activity
ratijas commentedon Nov 12, 2020
Also, when I cloned the repository, and loaded plugin from the latest master, errors slightly relocated:
phy1729 commentedon Nov 12, 2020
All of the referenced variables are declared global before being set. The test framework also sets WARN_CREATE_GLOBAL to catch issues like these. Could you see if something else in your configuration is necessary to reproduce the issue?
ratijas commentedon Nov 12, 2020
Interesting. I'm using my dotfiles repository, branch
zsh
. Relevant options might be in 11.options-user.zsh.https://github.com/ratijas/dotfiles/tree/zsh.
ratijas commentedon Nov 12, 2020
Looking briefly at the code, I don't even know what could be wrong with it, or how zsh imagines it should be.
The problem is reported at
ZSH_HIGHLIGHT_REVISION=HEAD
line.ratijas commentedon Nov 12, 2020
Oh, I'm sorry. I provided the wrong info. I have
WARN_NESTED_VAR
option on. Edited the top post.On a second thought, maybe I shouldn't be using this option. It seems too restrictive without obvious benefits. What do you think?
danielshahaf commentedon Nov 14, 2020
The error message under master is in the second post.
Given that the option exists, z-sy-h should support it. However, for
ZSH_HIGHLIGHT_REVISION
there is no reason why it would be set in the enclosing scope, and forZSH_HIGHLIGHT_HIGHLIGHTERS
, no reason why it would be set but empty in the enclosing scope. Which is to say, we're in need of a reproduction recipe.It seems to me that the option does have bug-finding potential. Feel free to discuss this further on zsh's support channels.
phy1729 commentedon Nov 15, 2020
I agree it seems silly to set in interactive use, but as @danielshahaf said we still ought to support it.
I can't reproduce the interactive bug, but this avoids warnings when the test harness sets WARN_NESTED_VAR
danielshahaf commentedon Nov 16, 2020
danielshahaf commentedon Nov 16, 2020
Which is to say: why don't we just unset the option? Cross-referencing #758.
FranklinYu commentedon Sep 14, 2021
update
Sorry for the spam. I wasn’t aware that this error message is about
warn_nested_var
instead ofwarn_create_global
. z-sy-h works perfectly underwarn_create_global
; I guess I’ll simply disablewarn_nested_var
.original comment
With my current Zsh configuration, I can reproduce the second bug:
This is weird since I can clearly see the variable set as global in
zsh-syntax-highlighting/highlighters/main/main-highlighter.zsh
Line 1841 in 6e0e950
I’ll try finding a minimal example to reproduce.
Revert "Warn about bad variable usage pattern for Zsh"