Andy - makes sense, I'm good with either interpretation, just thought you'd like to know about the internal error.
Ed.
From: "Andrew J. Schorr" <address@hidden>
To: "Ed Morton" <address@hidden>
Cc: address@hidden
Sent: Monday, October 7, 2013 10:11:48 AM
Subject: Re: [bug-gawk] gawk internal error on $i++
Ed,
On Mon, Oct 07, 2013 at 02:56:15PM +0000, Ed Morton wrote:
> Andy - mainly I expect never to see an error message that says "internal error" from any software. If/when I do see that (or get a core dump), I expect the author of the software to want to be informed as it indicates a bug in their software.
I agree. My intent was not to suggest otherwise.
> Beyond that - I expect this:
>
> $ awk 'BEGIN{ $i++ = 3; print i }'
> awk: cmd. line:1: fatal: internal error line 5032, file: awkgram.y
>
> to behave identically to either of these:
>
> $ awk 'BEGIN{ $(i++) = 3; print i }'
> 1
>
> $ awk 'BEGIN{ ($i)++ = 3; print i }'
> awk: cmd. line:1: BEGIN{ ($i)++ = 3; print i }
> awk: cmd. line:1: ^ syntax error
The operator precedence is explained here:
http://www.gnu.org/software/gawk/manual/html_node/Precedence.html
I believe your 2nd interpretation is correct. For example:
bash-4.1$ echo 1 2 3 | gawk '{i = 1; print $i; print $i++; print i; print}'
1
1
1
2 2 3
I think it should be a syntax error, but I was wondering if you had
a different interpretation.
Regards,
Andy