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

Incompatibility in syntax error when blank heredoc delimiters #996

Open
koic opened this issue Feb 26, 2024 · 0 comments
Open

Incompatibility in syntax error when blank heredoc delimiters #996

koic opened this issue Feb 26, 2024 · 0 comments

Comments

@koic
Copy link
Collaborator

koic commented Feb 26, 2024

There is an incompatibility in syntax error between Parser gem and Ruby:

$ cat example.rb
<<~''

Expected

<<~'' has been a syntax error since at least Ruby 2.0:

$ ruby -v example.rb
ruby 2.0.0p648 (2015-12-16 revision 53162) [x86_64-darwin13.0.2]
example.rb:1: syntax error, unexpected <<
<<~''
  ^

The same goes for Ruby 3.3:

$ ruby -v example.rb
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
example.rb:1: warning: possibly useless use of a literal in void context
example.rb: --> /tmp/h.rb
could not find a terminator for the heredoc
> 1  <<~''

Actual

Although the Parser gem is able to parse it, this is likely an unexpected behavior:

$ ruby-parse --33 example.rb
(dstr)

The same goes for <<'' and <<-''.

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