Skip Menu |
Report information
Id: 127945
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: alex.jakimenko [at] gmail.com
masak <cmasak [at] gmail.com>
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



To: rakudobug [...] perl.org
From: Carl Mäsak <cmasak [...] gmail.com>
Date: Thu, 21 Apr 2016 10:56:06 +0200
Subject: [BUG] <return> in a grammar calls &return in Rakudo, shouldn't
Download (untitled) / with headers
text/plain 1.1k
<ugexe> m: grammar Foo { token TOP { <return> }; token return { .+ }; }; Foo.parse(1); # bug? or dihwidt? <camelia> rakudo-moar 6df7ff: OUTPUT«Attempt to return outside of any Routine␤ in any !cursor_pass [...] <masak> ugexe: surprising, at least. a token is a kind of method, so why would that clash at all with `return` as a sub? <masak> m: grammar Foo { token TOP { <return> } }; Foo.parse("1") <camelia> rakudo-moar 6df7ff: OUTPUT«Attempt to return outside of any Routine␤ [...] <masak> ugexe: I think the problem isn't the declaration of `token return`, but the call `<return>`, which looks both for subs and methods... perhaps? <masak> and since there is a lexical sub &return, it finds it <jnthn> m: grammar Foo { token TOP { <return> } }; Foo.parse("1", actions => class { method return($/) { } }) <camelia> rakudo-moar 6df7ff: OUTPUT«Attempt to return outside of any Routine [...] <jnthn> masak: But it's only meant to find things of type Regex, I thought... * jnthn had suspected it was calling .return <jnthn> As an action method <jnthn> But apparently not, O did the action method wrong * masak submits rakudobug In summary, it seems to be calling &return, but it shouldn't do that.
Download (untitled) / with headers
text/plain 962b
Still present in rakudo 405519, except now one of the errors mentions "any !reduce" <Zoffix> m: grammar Foo { token TOP { <return> }; token return { .+ }; }; Foo.parse(1); <camelia> rakudo-moar 405519: OUTPUT«Attempt to return outside of any Routine␤ in any !reduce at /home/camelia/rakudo-m-inst-1/share/nqp/lib/QRegex.moarvm line 1␤ in any !cursor_pass at /home/camelia/rakudo-m-inst-1/share/nqp/lib/QRegex.moarvm line 1␤ in regex return at <tmp> line 1…» <Zoffix> m: grammar Foo { token TOP { <return> } }; Foo.parse("1", actions => class { method return($/) { } }) <camelia> rakudo-moar 405519: OUTPUT«Attempt to return outside of any Routine␤ in regex TOP at <tmp> line 1␤ in block <unit> at <tmp> line 1␤␤» <Zoffix> m: grammar Foo { token TOP { <return> } }; Foo.parse("1") <camelia> rakudo-moar 405519: OUTPUT«Attempt to return outside of any Routine␤ in regex TOP at <tmp> line 1␤ in block <unit> at <tmp> line 1␤␤»
Download (untitled) / with headers
text/plain 927b
♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ 🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁 TODO-fudged tests added in https://github.com/perl6/roast/commit/f4e2505dbc 🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁 ♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥ -- Cheers, ZZ | https://twitter.com/zoffix
Download (untitled) / with headers
text/plain 1.2k
On Sat Jul 09 19:02:23 2016, cpan@zoffix.com wrote: Show quoted text
> Still present in rakudo 405519, except now one of the errors mentions > "any !reduce" > > > <Zoffix> m: grammar Foo { token TOP { <return> }; token return { .+ }; > }; Foo.parse(1); > <camelia> rakudo-moar 405519: OUTPUT«Attempt to return outside of any > Routine␤ in any !reduce at /home/camelia/rakudo-m-inst- > 1/share/nqp/lib/QRegex.moarvm line 1␤ in any !cursor_pass at > /home/camelia/rakudo-m-inst-1/share/nqp/lib/QRegex.moarvm line 1␤ in > regex return at <tmp> line 1…» > <Zoffix> m: grammar Foo { token TOP { <return> } }; Foo.parse("1", > actions => class { method return($/) { } }) > <camelia> rakudo-moar 405519: OUTPUT«Attempt to return outside of any > Routine␤ in regex TOP at <tmp> line 1␤ in block <unit> at <tmp> line > 1␤␤» > <Zoffix> m: grammar Foo { token TOP { <return> } }; Foo.parse("1") > <camelia> rakudo-moar 405519: OUTPUT«Attempt to return outside of any > Routine␤ in regex TOP at <tmp> line 1␤ in block <unit> at <tmp> line > 1␤␤»
Ah, fun one. The problem is actually that after the return regex matches, it looks for actions. $*ACTIONS is likely set to Mu or Any if you don't supply an actions class. And Mu has a method return, which gets invoked.
Subject: “so” is not a valid token name (token so { abc })
Download (untitled) / with headers
text/plain 646b
Code: grammar A { token TOP { <so> }; token so { foo } }; say A.parse('foo') Result: Too many positionals passed; expected 1 argument but got 2 in any !reduce at /tmp/whateverable/rakudo-moar/58226059b53853134de0f265b6f46a923d2004e7/share/nqp/lib/QRegex.moarvm line 1 in any !cursor_pass at /tmp/whateverable/rakudo-moar/58226059b53853134de0f265b6f46a923d2004e7/share/nqp/lib/QRegex.moarvm line 1 in regex so at /tmp/1zrz_lKZXc line 1 in regex TOP at /tmp/1zrz_lKZXc line 1 in block <unit> at /tmp/1zrz_lKZXc line 1 Code: grammar A { token TOP { <kuso> }; token kuso { foo } }; say A.parse('foo') Result: 「foo」 kuso => 「foo」
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 935b
On Mon, 23 Jan 2017 01:02:07 -0800, alex.jakimenko@gmail.com wrote: Show quoted text
> Code: > grammar A { token TOP { <so> }; token so { foo } }; say A.parse('foo') > > Result: > Too many positionals passed; expected 1 argument but got 2 > in any !reduce at /tmp/whateverable/rakudo- > moar/58226059b53853134de0f265b6f46a923d2004e7/share/nqp/lib/QRegex.moarvm > line 1 > in any !cursor_pass at /tmp/whateverable/rakudo- > moar/58226059b53853134de0f265b6f46a923d2004e7/share/nqp/lib/QRegex.moarvm > line 1 > in regex so at /tmp/1zrz_lKZXc line 1 > in regex TOP at /tmp/1zrz_lKZXc line 1 > in block <unit> at /tmp/1zrz_lKZXc line 1 > > > > Code: > grammar A { token TOP { <kuso> }; token kuso { foo } }; say > A.parse('foo') > > Result: > 「foo」 > kuso => 「foo」
This is a dupe of RT#127945. Tokens with names of Mu methods invoke those on the default Actions class. The workaround is to override those in your own Actions class.
Download (untitled) / with headers
text/plain 180b
The aforementioned TODO fudge has been removed from the spec in https://github.com/perl6/roast/commit/6bf5aaebdd Re-add if this issue is resolved in the way the test expects it to.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org