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

Heredoc hash values have errant comma #61

Closed
gisikw opened this issue Nov 14, 2017 · 2 comments
Closed

Heredoc hash values have errant comma #61

gisikw opened this issue Nov 14, 2017 · 2 comments
Labels

Comments

@gisikw
Copy link

gisikw commented Nov 14, 2017

Hiya! Came across this issue when testing rufo's changes to a codebase. Rufo adds a trailing comma to hash args, which can break heredocs, as follows:

{
  content: <<-EOF
    This is a heredoc
  EOF
}

...gets transformed to

{
  content: <<-EOF
    This is a heredoc
  EOF,
]

Which will yield the error:

test.rb:5: can't find string "EOF" anywhere before EOF
test.rb:2: syntax error, unexpected end-of-input, expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END

In cases of heredocs, commas simply can't be placed without breaking the terminator.

@gingermusketeer
Copy link
Member

Thanks for reporting this. I think the expected behavior, with trailing commas enabled, would be:

{
  content: <<-EOF,
    This is a heredoc
  EOF
}

I get a syntax error with:

{
  content: <<-EOF
    This is a heredoc
  EOF
  , 
}

Does that sound correct to you?

@gisikw
Copy link
Author

gisikw commented Nov 14, 2017

Yep, counterintuitive as it looks, that seems to work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants