bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] gawk internal error on $i++


From: Andrew J. Schorr
Subject: Re: [bug-gawk] gawk internal error on $i++
Date: Mon, 7 Oct 2013 11:11:48 -0400
User-agent: Mutt/1.5.21 (2010-09-15)

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]