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

Error during inspect: undefined local variable or method 'root' #193

Open
Phrogz opened this issue Apr 14, 2018 · 2 comments
Open

Error during inspect: undefined local variable or method 'root' #193

Phrogz opened this issue Apr 14, 2018 · 2 comments
Assignees

Comments

@Phrogz
Copy link

Phrogz commented Apr 14, 2018

I have a web app using my Flooph gem, which is a class inheriting from Parslet::Parser. When I get certain web app errors, it tries to inspect my class, resulting in a new error (that masks my web app's error). Here's a simple repro:

phrogz$ ruby -e "require 'flooph'; p Flooph.new"
Traceback (most recent call last):
	4: from -e:1:in `<main>'
	3: from -e:1:in `p'
	2: from /Users/phrogz/.rvm/gems/ruby-2.5.1/gems/parslet-1.8.2/lib/parslet/atoms/base.rb:148:in `inspect'
	1: from /Users/phrogz/.rvm/gems/ruby-2.5.1/gems/parslet-1.8.2/lib/parslet/atoms/base.rb:140:in `to_s'
/Users/phrogz/.rvm/gems/ruby-2.5.1/gems/parslet-1.8.2/lib/parslet/parser.rb:66:in `to_s_inner': undefined local variable or method `root' for #<Flooph:0x00007fd635845770> (NameError)

This happens because my class does not define a root rule before it gets inspected.

@Phrogz
Copy link
Author

Phrogz commented Apr 14, 2018

Since I've just patched my gem to avoid this bug, the simpler repro is:
ruby -e "require 'parslet'; p Parslet::Parser.new"
…but it will happen when trying to inspect any parser that doesn't have a root rule.

@kschiess kschiess self-assigned this Apr 16, 2018
@kschiess
Copy link
Owner

Good catch. I'll work on this as soon as I get around to it. Thank you for the report!

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

2 participants