From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Peter Stephenson <p.stephenson@samsung.com>
Cc: zsh-workers@zsh.org
Subject: Re: LOCAL_VARS option ?
Date: Wed, 25 Jan 2017 19:32:02 +0000 [thread overview]
Message-ID: <20170125193202.GA17866@fujitsu.shahaf.local2> (raw)
In-Reply-To: <20170125092438.215f5a2c@pwslap01u.europe.root.pri>
Peter Stephenson wrote on Wed, Jan 25, 2017 at 09:24:38 +0000:
> On Wed, 25 Jan 2017 05:50:09 +0000
> Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> > This case seems to be a false positive:
> >
> > % () { typeset -A a; : ${a[hello world]::=foo} }
> > (anon): scalar parameter hello world set in enclosing scope in function (anon)
>
> There's a bogus parameter created for assistance in this case. I didn't
> see what was going on so I didn't turn off the new warning.
Thanks for the fix.
> By the way, you won't get a warning in a case like this:
>
> () {
> local var=(one two)
> () { var[3]=three; }
> print $var
> }
>
> which is probably OK because setting an element of something already
> presupposes it exists.
>
It does warn if the inner function assigns «var[3]=(three)». I suppose
it shouldn't, for the same reason as the above case?
That would also enable «var[1,-1]=(...)» as an idiom to intentionally
overwrite an array declared in a parent function, without using the
reserved word 'typeset -ga' syntax. (which is useful for scripts that
need to be compatible with older zsh's)
> The WARN_CREATE_GLOBAL equivalent does operate here, so you're
> protected if it doesn't exist. You also get a warning if you trash
> the whole array:
>
> () {
> local var=(one two)
> () { var=(three); }
> print $var
> }
Cheers,
Daniel
> However, you don't get a warning if you change the array to something
> else:
>
> () {
> local var=(one two)
> () { var=three; }
> print $var
> }
>
> That's a crucial case for protecting against problems and needs looking
> at in the tortuous type conversion logic.
next prev parent reply other threads:[~2017-01-25 19:35 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20170119070023epcas3p17d787fb31e7c04d5bcf2231020769b5f@epcas3p1.samsung.com>
2017-01-19 6:54 ` Daniel Shahaf
2017-01-19 9:43 ` Jens Elkner
2017-01-19 9:45 ` Peter Stephenson
2017-01-19 15:47 ` Bart Schaefer
2017-01-19 16:08 ` Peter Stephenson
2017-01-20 5:01 ` Bart Schaefer
2017-01-20 17:19 ` Peter Stephenson
2017-01-22 18:45 ` Bart Schaefer
2017-01-22 19:00 ` Peter Stephenson
2017-01-23 10:09 ` Peter Stephenson
2017-01-23 11:20 ` Daniel Shahaf
2017-01-23 11:37 ` Peter Stephenson
2017-01-25 5:50 ` Daniel Shahaf
2017-01-25 9:24 ` Peter Stephenson
2017-01-25 19:32 ` Daniel Shahaf [this message]
2017-01-25 21:50 ` Bart Schaefer
2017-01-29 21:21 ` Daniel Shahaf
2017-01-26 19:43 ` Peter Stephenson
2017-01-26 20:04 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170125193202.GA17866@fujitsu.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--cc=p.stephenson@samsung.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).