Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Possibly excessive WARN_CREATE_GLOBAL



On Nov 22,  6:27pm, Peter Stephenson wrote:
} Subject: Re: Possibly excessive WARN_CREATE_GLOBAL
}
} On Sun, 22 Nov 2015 09:52:12 -0800
} Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
} > However, do we want to be complaining about REPLY, reply, match, mbegin,
} > mend, MBEGIN, MEND, and BASH_REMATCH?
}  
} Yes, those are exactly the ones where it's important we do --- in fact,
} match etc. were in my mind when I introduced the option [...]
} 
} (Unfortunately, in this example we don't actually get a warning for the
} inner scope if the outer function had already localised the variable
} [...].  You could argue for a warning "variable created in outer
} scope", I suppose.)

Hmm.

No time to fix it now, but declaring something "private" suppresses the
warncreateglobal warning without allowing the variable to become set in
the inner scope.  (What SHOULD happen here?  An error?)

torch% zmodload zsh/param/private
torch% setopt extendedglob warncreateglobal
torch% () {
 local -P match
 () {
  [[ abc = (#b)*(?)* ]]
  typeset -p match mbegin mend
 }
 print ${(t)match}
}
(anon):1: array parameter mbegin created globally in function (anon)
(anon):1: array parameter mend created globally in function (anon)
(anon):typeset:2: no such variable: match
typeset -a mbegin
mbegin=( 3 )
typeset -a mend
mend=( 3 )
scalar-local-hide-hideval-special



Messages sorted by: Reverse Date, Date, Thread, Author