On Sat Jan 17 14:17:17 2009, masak wrote:
> <masak> rakudo: if 5 > my $a = 4 { say $a }
> <p6eval> rakudo 35707: OUTPUT«Unable to set lvalue on PAST::Val node [...]
> <masak> it works if I use parens, but what does that error mean?
> <jnthn> Hmm.
> <jnthn> masak: What's the next line down in the backtrace?
> <masak> called from Sub 'parrot;PAST;Compiler;as_post' pc 4013
> (src/PAST/Compiler.pir:986)
> <jnthn> Ah, damm. It's failed in the PAST->POST.
> * masak submits rakudobug

Since the relational ops are tighter than assignment, the expression in

    if 5 > my $a = 4 { ... }

parses as

    if (5 > my $a) = 4 { ... }

and of course we can't assign to the lvalue result of the comparison, as
somewhat opaquely indicated by the error message.  (PCT complains
because it's ultimately trying to make the constant '5' into an lvalue,
so we probably need to find a way to improve the error message here.)

At any rate, it appears that the parens are needed around the (my $a =
4), so Rakudo is at least recognizing the statement as an error.

I'll see if I can improve the PAST diagnostic to somehow give a better
error indication.

Pm

Reply via email to