Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [bug] Math evaluation done twice in subscript in specific conditions
- X-seq: zsh-workers 44569
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: [bug] Math evaluation done twice in subscript in specific conditions
- Date: Wed, 24 Jul 2019 07:33:08 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=FlOeYySprnrSkD78cFIVV0aFv9xJyCfXBJkzmMKB468=; b=vKG5QOumJxhi8qabnPRCFCCQr0xo/5wGwqcoC9x1xuBan63Wk2VToc3fHm3oJJf6WA iQoAcImTTvrNzUQumhSgRwE15hMk16K+AZNo6E/nUl6e099IDx+jk9C+3eF7xrYYTjo6 ytcpth4yr9TfBWnPC5O6eEmSnMBQk4sL5mCRH6WF5z28OmgjP0BC1YsxSre2IQaPjtoX VbSnTV8vzoR9SW9VbaoVbp56Q8/udOWaNiMbmOkDzl8DAOLN+1VkkvP5fhtv48h3t1kl 4ubtp28Mp9coJpRk8YSI2blGJI1aJF5O+3rWcN2TceaQC0m4QDl9eVyd8GZVHAA4y8tX aFog==
- In-reply-to: <20190724051234.5yky2pd5pxv5z3lu@chaz.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVBZa=G0D1v4u9=257O20N85r26HWmjtpxVrNvfoUp-PSQ@mail.gmail.com> <20190724051234.5yky2pd5pxv5z3lu@chaz.gmail.com>
On Wed, 24 Jul 2019 at 07:12, Stephane Chazelas
<stephane.chazelas@xxxxxxxxx> wrote:
>
> 2019-07-24 01:50:23 +0200, Sebastian Gniazdowski:
> [...]
> > idx=0
> > a=()
> > : ${a[++idx]::=$idx}
> > print -rl $a
> > -> 1
> > : ${a[++idx]::=$idx}
> > print -rl $a
> > -> 1
> > -> 3
> > idx=1
> > : ${a[++idx]::=$idx}
> > print -rl $a
> > -> 1
> > -> 2
> > -> 3
> >
> > So apparently the assignment to idx does change something for the
> > following ::= "call" and makes it work correctly. The second and
> > following ::= calls cause $idx to increment twice.
> [...]
>
> It is increased by 2 on the first one as well:
>
> $ i=0 a=()
> $ : ${a[++i]::=$i}; echo $i $a
> 2 1
> $ : ${a[++i]::=$i}; echo $i $a
> 4 1 3
Ah, of course.
> It makes more sense in that latter case where I imaging a[i] is
> dereferenced first to check if it's empty or not, and then the
> indice is computed again upon assignment.
When I was debugging Zsh in the past, I've very often occurred double
getter call AFAIR, or at least of something underneath. It is basic to
assume that this would call mathevali twice. I was then thinking that
it is like that by design and didn't report it.
--
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org
Messages sorted by:
Reverse Date,
Date,
Thread,
Author