[ruby-core:117755] [Ruby master Bug#20465] parse.y adds an extra empty string to the AST
From:
"mame (Yusuke Endoh) via ruby-core" <ruby-core@...>
Date:
2024-05-02 23:55:23 UTC
List:
ruby-core #117755
Issue #20465 has been updated by mame (Yusuke Endoh).
How would this be a problem?
I think it intentionally creates the structure to ensure that it returns a new String object. Unlike #20457, there is no lack of information. I don't think it is so inconvenient.
----------------------------------------
Bug #20465: parse.y adds an extra empty string to the AST
https://bugs.ruby-lang.org/issues/20465#change-108161
* Author: tenderlovemaking (Aaron Patterson)
* Status: Open
* ruby -v: ruby 3.4.0dev (2024-05-02T15:27:18Z master 7c0cf71049) [arm64-darwin23]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
Given this code:
```ruby
t0 = '\\xc1'
"#{t0}"
```
The AST is like this:
```
$ ./miniruby --dump=parsetree test.rb
###########################################################
## Do NOT use this node dump for any purpose other than ##
## debug and research. Compatibility is not guaranteed. ##
###########################################################
# @ NODE_SCOPE (id: 8, line: 1, location: (1,0)-(2,7))
# +- nd_tbl: :t0
# +- nd_args:
# | (null node)
# +- nd_body:
# @ NODE_BLOCK (id: 6, line: 1, location: (1,0)-(2,7))
# +- nd_head (1):
# | @ NODE_LASGN (id: 0, line: 1, location: (1,0)-(1,12))*
# | +- nd_vid: :t0
# | +- nd_value:
# | @ NODE_STR (id: 1, line: 1, location: (1,5)-(1,12))
# | +- string: "\\xc1"
# +- nd_head (2):
# @ NODE_DSTR (id: 4, line: 2, location: (2,0)-(2,7))*
# +- string: ""
# +- nd_next->nd_head:
# | @ NODE_EVSTR (id: 3, line: 2, location: (2,0)-(2,7))
# | +- nd_body:
# | @ NODE_LVAR (id: 2, line: 2, location: (2,3)-(2,5))
# | +- nd_vid: :t0
# +- nd_next->nd_next:
# (null node)
```
There is an empty DSTR. I don't think that DSTR should be there since it's not part of the source.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/