[ruby-core:124627] [Ruby Bug#21849] Ripper.lex emits two `tstring_content` for single string in edge-case
Issue #21849 has been reported by Earlopain (Earlopain _). ---------------------------------------- Bug #21849: Ripper.lex emits two `tstring_content` for single string in edge-case https://bugs.ruby-lang.org/issues/21849 * Author: Earlopain (Earlopain _) * Status: Open * ruby -v: ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [x86_64-linux] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- ```rb Ripper.lex('"x#$%"') => [[[1, 0], :on_tstring_beg, "\"", BEG], [[1, 1], :on_tstring_content, "x", BEG], [[1, 2], :on_tstring_content, "\#$%", BEG], [[1, 5], :on_tstring_end, "\"", END]] ``` It seems like ripper sees `#$` and assumes that this is bare interpolation. However, `$%` is not a valid global name. So I think it should instead be a single `tstring_content`: ```rb [[[1, 0], :on_tstring_beg, "\"", BEG], [[1, 1], :on_tstring_content, "x\#@%", BEG], [[1, 5], :on_tstring_end, "\"", END]] ``` I stumbled across this in the prism translator for ripper. Prism only emits a single token for the string. -- https://bugs.ruby-lang.org/
participants (1)
-
Earlopain (Earlopain _)