Skip to content

Parser fails to tokenize ERB with two subsequent returning expressions #3550

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

Open
leoarnold opened this issue Apr 16, 2025 · 2 comments · May be fixed by #3551
Open

Parser fails to tokenize ERB with two subsequent returning expressions #3550

leoarnold opened this issue Apr 16, 2025 · 2 comments · May be fixed by #3551

Comments

@leoarnold
Copy link

Using Prism 1.4.0 on Ruby 3.4.3 I get

3.4.3 :002 > buffer = Parser::Source::Buffer.new('foo.erb')
 => #<Parser::Source::Buffer foo.erb> 
3.4.3 :003 > buffer.source = "<%= a %>"
 => "<%= a %>" 
3.4.3 :004 > Prism::Translation::Parser34.new.tokenize(buffer)
 => [nil, [], [[:tLT, ["<", #<Parser::Source::Range foo.erb 0...1>]], [:tSTRING_BEG, ["%=", #<Parser::Source::Range foo.erb 1...3>]], [:tSTRING_CONTENT, [" a %>", #<Parser::Source::Range foo.erb 3...8>]]]] 
3.4.3 :005 > buffer = Parser::Source::Buffer.new('bar.erb')
 => #<Parser::Source::Buffer bar.erb> 
3.4.3 :006 > buffer.source = "<%= a %><%= b ? c : d %>"
 => "<%= a %><%= b ? c : d %>" 
3.4.3 :007 > Prism::Translation::Parser34.new.tokenize(buffer)
(smart-workspaces):7:in '<main>': undefined method '[]' for nil (NoMethodError)

              next_next_token = lexed[index + 1][0]
                                                ^^^
@Earlopain Earlopain linked a pull request Apr 17, 2025 that will close this issue
@Earlopain
Copy link
Contributor

Thanks for the report! I openend #3551 for a different issue, but it will fix your problem as well.

@leoarnold
Copy link
Author

@Earlopain Awesome!

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

Successfully merging a pull request may close this issue.

2 participants