perl6 / nqp-rx

(ARCHIVE) nqp-rx
Artistic License 2.0
37 stars 6 forks source link

"next()" Creates bad PIR #5

Open Whiteknight opened 14 years ago

Whiteknight commented 14 years ago

http://gist.github.com/455249

In this gist, the keyword "next" is called like a function with "next()". I'm not sure if this would be valid Perl6 or not, but the generated PIR has this snippet:

set $I13, .CONTROL_LOOP_NEXT
die 0, $I13
$P14 = ()

This is a PIR parse error and Parrot barfs over it.

arnsholt commented 14 years ago

The cause of this issue is, as far as I can make out, that the loop control primitives are implemented as special instances of term:sym<> that generate custom PAST. When those terms are followed by a postcircumfix:sym<( )>, things go a bit pear-shaped.

I think the problem is that method postcircumfix<( )> in Actions.pm generates a call op, but it looks like term:sym suppresses the setting of the invocant, which creates the $P14 = () code (which should really be $P14 = "foo"() or somesuch).

A quick fix that works for me locally is to add `[ '(' ~ ')' <.arglist>]? to term:sym, but it's most likely not an ideal fix.