From: "byroot (Jean Boussier) via ruby-core" Date: 2026-11-09T11:36:09+00:00 Subject: [ruby-core:127375] [Ruby Bug#22519] Incompatibility between parse.y and Prism in the encoding of interpolated strings Issue #22519 has been updated by byroot (Jean Boussier). Yes, Parse.y puts an extra empty string with the final encoding: ``` 0003 putobject "" 0005 getlocal_WC_0 x@0 0007 dup 0008 objtostring 0010 anytostring 0011 getlocal_WC_0 x@0 0013 dup 0014 objtostring 0016 anytostring 0017 concatstrings 3 ``` Whereas prism elude it: ``` 0003 getlocal_WC_0 x@0 0005 dup 0006 objtostring 0008 anytostring 0009 getlocal_WC_0 x@0 0011 dup 0012 objtostring 0014 anytostring 0015 concatstrings 2 ``` ---------------------------------------- Bug #22519: Incompatibility between parse.y and Prism in the encoding of interpolated strings https://bugs.ruby-lang.org/issues/22519#change-119808 * Author: mame (Yusuke Endoh) * Status: Open * Assignee: prism * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- There seems to be an incompatibility between parse.y and Prism in the encoding of interpolated strings. ```ruby # in a script file x = 1 p "#{x}#{x}".encoding # parse.y: # prism: # a = "abc".force_encoding("US-ASCII") b = "".encode("UTF-16LE") s = "#{a}#{b}" p s.encoding # parse.y: # prism: # p s # parse.y: "abc" prism: "\u6261\x63" ``` @naruse says the behavior of parse.y is correct. This is probably a bug in the Prism compiler, but I have not looked into it in detail. With `-e`, the result of parse.y seems to depend on the locale encoding (the `LANG` environment variable). I have not looked into the details of this either. -- 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/lists/ruby-core.ml.ruby-lang.org/