Project

General

Profile

Actions

Bug #21849

open

Ripper.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
1

Added by Earlopain (Earlopain _) 2 days ago.

Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [x86_64-linux]
[ruby-core:124627]

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

Also available in: PDF Atom