mirror of
https://github.com/ruby/ruby.git
synced 2025-08-28 07:26:00 +02:00
![]() 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.
|
||
---|---|---|
.. | ||
parse_result | ||
polyfill | ||
translation | ||
debug.rb | ||
desugar_compiler.rb | ||
ffi.rb | ||
lex_compat.rb | ||
node_ext.rb | ||
node_inspector.rb | ||
pack.rb | ||
parse_result.rb | ||
pattern.rb | ||
prism.gemspec | ||
translation.rb |