You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ruby heredoc in method arguments breaks parenthese recognition #124
@alexr00 the heredoc content starts from the line following the heredoc identifier (LOG in our case) and we can use the heredoc identifier as a variable in that line, so log(<<-LOG) is a valid function call and <<-LOG is referring to the content after this line (and also ends with LOG). https://docs.ruby-lang.org/en/2.5.0/syntax/literals_rdoc.html
For short, ) is not part of the multiline string, our grammar is kind of wrong.
changed the title [-]Ruby heredoc in method arguments break braces syntax[/-][+]Ruby heredoc in method arguments breaks parenthese recognition[/+]on Nov 20, 2018
Activity
alexr00 commentedon Nov 20, 2018
From @amerov on November 18, 2018 7:54
@alexr00 It is valid ruby code.
Examples:
https://github.com/rails/rails/blob/master/activemodel/lib/active_model/attributes.rb#L35
https://github.com/rails/rails/blob/master/activerecord/lib/active_record/persistence.rb#L659
https://github.com/rails/rails/blob/master/activerecord/lib/active_record/nested_attributes.rb#L370
alexr00 commentedon Nov 20, 2018
From @rebornix on November 19, 2018 17:7
@alexr00 the heredoc content starts from the line following the heredoc identifier (
LOGin our case) and we can use the heredoc identifier as a variable in that line, solog(<<-LOG)is a valid function call and<<-LOGis referring to the content after this line (and also ends withLOG). https://docs.ruby-lang.org/en/2.5.0/syntax/literals_rdoc.htmlFor short,
)is not part of the multiline string, our grammar is kind of wrong.alexr00 commentedon Nov 20, 2018
Thanks for checking!
[-]Ruby heredoc in method arguments break braces syntax[/-][+]Ruby heredoc in method arguments breaks parenthese recognition[/+]