diff options
author | Earlopain <[email protected]> | 2025-01-13 16:31:41 +0100 |
---|---|---|
committer | git <[email protected]> | 2025-01-13 15:43:24 +0000 |
commit | 0a26a3de8955e90ef63c238b1469981648e804de (patch) | |
tree | aad686cb70cdff5d49e52e0574784c338c9d496a /lib | |
parent | eab1f02149cdebf5caab2fd61cc1cd448b5d5497 (diff) |
[ruby/prism] Fix parser translator heredoc dedention with leading interpolation
```rb
<<~F
foo
#{}
bar
F
```
has zero common whitespace.
https://github.com/ruby/prism/commit/1f3c222a06
Diffstat (limited to 'lib')
-rw-r--r-- | lib/prism/translation/parser/lexer.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/prism/translation/parser/lexer.rb b/lib/prism/translation/parser/lexer.rb index 1808473cad..ace40df5d8 100644 --- a/lib/prism/translation/parser/lexer.rb +++ b/lib/prism/translation/parser/lexer.rb @@ -569,6 +569,11 @@ module Prism # String content inside nested heredocs and interpolation is ignored if next_token.type == :HEREDOC_START || next_token.type == :EMBEXPR_BEGIN + # When interpolation is the first token of a line there is no string + # content to check against. There will be no common whitespace. + if nesting_level == 0 && next_token.location.start_column == 0 + result = 0 + end nesting_level += 1 elsif next_token.type == :HEREDOC_END || next_token.type == :EMBEXPR_END nesting_level -= 1 |