Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem when reentering the grammar engine from an action #4621

Closed
p6rt opened this issue Oct 5, 2015 · 5 comments
Closed

Problem when reentering the grammar engine from an action #4621

p6rt opened this issue Oct 5, 2015 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Oct 5, 2015

Migrated from rt.perl.org#126263 (status was 'rejected')

Searchable as RT126263$

@p6rt
Copy link
Author

p6rt commented Oct 5, 2015

From @cognominal

grammar G { token TOP() { 'a' } }
class A { method TOP($/) { G.parse('a'); } }
G.parse('a', :actions(A));

=begin pod

  perl6 u
  Cannot assign to a readonly variable or a value
  in method TOP at u​:2
  in regex TOP at u​:1
  in block <unit> at u​:3

The example is pretty stupid because it would lead to a infinite recursion.
This is just a golfed version of a real example which used a grammar to drive tests
on another grammar that led to the same error.

=end pod

@p6rt
Copy link
Author

p6rt commented Oct 5, 2015

From @timo

The thing is that G.parse('a') puts (well, tries to put) the parse
result into $/. $/ is a part of your method's signature and by default
those are read-only. That's why you're being accused of assigning to a
readonly variable.

what you'll need to do is either call the parameter something else or
put G.parse('a') into an inner scope that defines its own $/.

I'm willing to close this as "notabug".

@p6rt
Copy link
Author

p6rt commented Oct 5, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Oct 5, 2015

From @cognominal

On Mon Oct 05 05​:14​:25 2015, timo wrote​:

The thing is that G.parse('a') puts (well, tries to put) the parse
result into $/. $/ is a part of your method's signature and by default
those are read-only. That's why you're being accused of assigning to a
readonly variable.

what you'll need to do is either call the parameter something else or
put G.parse('a') into an inner scope that defines its own $/.

I'm willing to close this as "notabug".

Indeed nothing obliged me to use $/ as a parameter.
On the other hand, the error message does not tell what is the problematic variable.
Thx.

@p6rt
Copy link
Author

p6rt commented Oct 5, 2015

@cognominal - Status changed from 'open' to 'rejected'

@p6rt p6rt closed this as completed Oct 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant