Actions
Bug #21849
openRipper.lex emits two `tstring_content` for single string in edge-case
Bug #21849:
Ripper.lex emits two `tstring_content` for single string in edge-case
Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [x86_64-linux]
Description
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:
[[[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.
No data to display
Actions