# New Ticket Created by "Carl Mäsak" # Please include the string: [perl #127945] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/Ticket/Display.html?id=127945 >
<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.