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
NoMethodError: undefined method `type' #141
Comments
@catmando BTW I can only reproduce this via your script if I enable the modern Ruby AST: Parser::Builders::Default.emit_lambda = true
Parser::Builders::Default.emit_procarg0 = true
Parser::Builders::Default.emit_encoding = true
Parser::Builders::Default.emit_index = true |
@catmando And more: The modern Ruby AST documentation is incomplete, which I just corrected with a pull request to parser. To get your example parsing you need to switch on: Or you use |
@catmando I'm closing this as I'm confident your issue will be resolved once you activate the modern AST format. Please reopen if its not the case. |
@mbj Thanks! I can't remember why, but I needed modern AST. However adding Also thanks for this Gem. Its an absolute key component of a gem called hyper-spec. Hyper-spec lets you write rspec expectations that will run on the client (using the Opal -> JS transpiler) So you can write a spec like this: it "can load isomorphic code using the isomorphic method" do
isomorphic do # this executes on both the client and the server
def factorial(n)
n==1 ? 1 : n * factorial(n-1)
end
end
expect_evaluate_ruby do
factorial(5) # this runs on the client in the browser (or headless browser)
end.to eq(factorial(5))
end we use parser to parse the code and extract the code in the blocks, then use unparser to get in back into ruby, then the opal compiler to translate it to javascript. We have 1000's of specs written like this, and it lets us code everything in ruby, so a huge thanks to you. |
The following AST
throws this error:
on version
>= '0.4.6'
and `0.4.7. (0.4.5 works fine.)The precise code is as follows:
Parser::CurrentRuby == Parser::Ruby26
(parser v 2.6.5.0)
The text was updated successfully, but these errors were encountered: