From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29078 invoked by alias); 25 Jan 2017 19:35:57 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 40418 Received: (qmail 21394 invoked from network); 25 Jan 2017 19:35:57 -0000 X-Qmail-Scanner-Diagnostics: from out1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.25):SA:0(-0.7/5.0):. Processed in 1.563221 secs); 25 Jan 2017 19:35:57 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= mesmtp; bh=vnsfE0Qppu2dIKR0SWkKFpIL/y0=; b=Frwxfj5AreX/dgk4pKPxy lpu/hviZe5kxjdKGoG9twFatXBTfElQLUzaDZZDJfPWkX3N6o3qgUWB/nCbrXnIu O34HlcPROM/lJmnfAGZ7C5ar4BBAZX2Av+fg0lCXle/KbcTE4gLkf3f/fYZZIxhZ Go13vAmKTIgqlXH7LEPsJo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= smtpout; bh=vnsfE0Qppu2dIKR0SWkKFpIL/y0=; b=f1lbK18re03VyyfFA6mK H/6LgWxEEM5uRTX68HcGUys9rR/bMQdLjU1qnjGqk21eCAvfYNvefK17tVcmHuhJ dkkYBIPIHwxkWz1iaSoE1Ayak4bwAc8nLb32g384xeW59hLOI8mvth5QcfUQca8a t8tKuvVvjukbvFi9TK9Vj+A= X-ME-Sender: X-Sasl-enc: 1m1BW4bPcD0QSU5byf6XSokfjZBxaakN4svzZ3MhMONC 1485372946 Date: Wed, 25 Jan 2017 19:32:02 +0000 From: Daniel Shahaf To: Peter Stephenson Cc: zsh-workers@zsh.org Subject: Re: LOCAL_VARS option ? Message-ID: <20170125193202.GA17866@fujitsu.shahaf.local2> References: <20170119160841.354ec75c@pwslap01u.europe.root.pri> <20170120171922.0e0c370d@pwslap01u.europe.root.pri> <20170122190052.327898df@ntlworld.com> <20170123100914.55675852@pwslap01u.europe.root.pri> <20170123112008.GA8944@fujitsu.shahaf.local2> <20170125055009.GA11466@fujitsu.shahaf.local2> <20170125092438.215f5a2c@pwslap01u.europe.root.pri> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20170125092438.215f5a2c@pwslap01u.europe.root.pri> User-Agent: Mutt/1.5.23 (2014-03-12) Peter Stephenson wrote on Wed, Jan 25, 2017 at 09:24:38 +0000: > On Wed, 25 Jan 2017 05:50:09 +0000 > Daniel Shahaf 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.