ruby/lib/prism
Stan Lo 0924ff2d39 [ruby/prism] Fix parser translation's heredoc whitespace calculation
Given this example:

```rb
<<~HEREDOC
  #{x}
HEREDOC
```

Both the parser gem and Prism's translation layer would generate the following AST:

```
s(:dstr,
  s(:begin,
    s(:int, 1)),
  s(:str, " a\n"))
```

However, the parser gem inserts a empty string node into this node's location, like:

```
<Parser::Source::Map::Heredoc:0x0000000104ce73b8
 @expression=#<Parser::Source::Range (string) 0...10>,
 @heredoc_body=#<Parser::Source::Range (string) 11...20>,
 @heredoc_end=#<Parser::Source::Range (string) 20...27>,
 @node=s(:dstr,
  s(:str, ""),
  s(:begin,
    s(:int, 1)),
  s(:str, " a\n"))>
```

This is required to calculate the correct whitespace for the heredoc body.

We need to adjust the translation layer to account for this.

With this fix, we also won't need to ignore the tilde heredoc fixture anymore.

e7372e3ba5
2024-04-12 13:55:35 +00:00
..
parse_result [ruby/prism] Fix some type-checking errors by using different method calls 2024-03-06 21:37:52 +00:00
polyfill [ruby/prism] Move polyfill to separate file to type-check it independently. 2024-03-06 21:37:53 +00:00
translation [ruby/prism] Fix parser translation's heredoc whitespace calculation 2024-04-12 13:55:35 +00:00
debug.rb [ruby/prism] Use steep to type check RBS and Ruby files 2024-02-24 03:39:19 +00:00
desugar_compiler.rb [ruby/prism] Add Location#chop 2024-04-11 18:53:30 +00:00
ffi.rb [ruby/prism] CLI -x flag 2024-03-28 12:04:35 -04:00
lex_compat.rb [ruby/prism] Fix IgnoredNewlineToken comparison of Ripper::Lexer::State 2024-02-24 03:39:20 +00:00
node_ext.rb [ruby/prism] Freeze internal parts, again 2024-03-26 12:11:09 -04:00
node_inspector.rb [ruby/prism] More Ruby docs 2023-11-01 13:10:29 -04:00
pack.rb [ruby/prism] Resync RBI and test it in CI 2024-02-29 16:29:16 +00:00
parse_result.rb [ruby/prism] Add Location#chop 2024-04-11 18:53:30 +00:00
pattern.rb [ruby/prism] Less code modifications. More steep:ignore for now 2024-02-24 03:39:28 +00:00
prism.gemspec [ruby/prism] Bump to v0.25.0 2024-04-05 21:44:06 +00:00
translation.rb [ruby/prism] Fix up some minor parser incompatibilities 2024-03-04 14:39:52 +00:00