Skip to content

Wrong token location for "\C-(newline)" #3987

Closed

Description

@tompng

Token location of this ruby code seems wrong.

"\C-
"
Prism.lex("\"\\C-\n\"").value[1]
#=> [STRING_CONTENT(1,1)-(1,5)("\\C-\n"), 1]

This token ends with newline, so I think the location should be (1,1)-(2,0)

Another example for an incomplete string literal:

Prism.lex("\"\\C-\naaa\nbbb").value[1]
=> [[STRING_BEGIN(1,0)-(1,1)("\""), 1], [STRING_CONTENT(1,1)-(2,0)("\\C-\naaa\n"), 1], [STRING_CONTENT(2,0)-(2,3)("bbb"), 1], [EOF(2,3)-(2,3)(""), 1]]

(1,1)-(2,0) should be (1,1)-(2,3), (2,0)-(2,3) should be (3,0)-(3,3)
or perhaps two tokens should be concatenated: (1,1)-(3,3)

Found while typing "\C-a" to irb-head. (IRB appends \n when analyzing code).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions