Re: Parser’ s bug? Parentheses in an "s"-type argument

Bill Allombert <[email protected]>
Newsgroups gmane.comp.mathematics.pari.devel
Message-ID <Yj2OmblvueFszkvP@seventeen>
On Thu, Mar 24, 2022 at 08:20:58PM -0700, Ilya Zakharevich wrote:
> I’m not sure it is a bug (do not know whether the syntax is
> documented anywhere), but this definitely makes it harder to write a
> readable code.
> 
> (19:23) gp > my(a=0,b=1);print(a"\t"(a+=b))
>   ***   at top-level: my(a=0,b=1);print(a"\t"(a+=b))
>   ***                                    ^-----------
>   ***   not a function in function call

This is not a bug, this is an ambiguous case.
You should just add commas:
my(a=0,b=1);print(a,"\t",(a+=b))

Omitting the commas is only supported for backward compatibility
and is discouraged.

What happen here is that 
print(a"\t"a+=b) is parsed as 
print(a<ERROR>"\t"<ERROR>a+=b)
and the <ERROR> token are replaced by ','
but
print(a"\t"(a+=b)) is parsed as 
print(a<ERROR>"\t"(a+=b))
because for the parser point of view, "\t"(a+=b) is a function call,
not a syntax error.

Cheers,
Bill.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.