From: "nobu (Nobuyoshi Nakada) via ruby-core" Date: 2024-05-07T04:03:52+00:00 Subject: [ruby-core:117786] [Ruby master Bug#20465] parse.y adds an extra empty string to the AST Issue #20465 has been updated by nobu (Nobuyoshi Nakada). tenderlovemaking (Aaron Patterson) wrote in #note-2: > It's not a problem for the compiler (of course), but a problem for the language server use case. Users didn't write `""` there, so consumers of the AST will have to detect and handle this case. If the AST is supposed to reflect the source document, then I would expect there to _not_ be a `""` node. I think it should be there, since there is an empty string part before `#`. ---------------------------------------- Bug #20465: parse.y adds an extra empty string to the AST https://bugs.ruby-lang.org/issues/20465#change-108193 * 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/