Skip to content

Prism accepts ("a":) as a symbol literal with parenthese, but Ruby rejects it #3035

@makenowjust

Description

@makenowjust

Bug report

Example code:

("a":)

Ruby:

-e:1: syntax error, unexpected tLABEL_END, expecting literal content or terminator or tSTRING_DBEG or tSTRING_DVAR
("a":)

Prism:

@ ProgramNode (location: (1,0)-(1,6))
├── flags: 
├── locals: []
└── statements:
    @ StatementsNode (location: (1,0)-(1,6))
    ├── flags: 
    └── body: (length: 1)
        └── @ ParenthesesNode (location: (1,0)-(1,6))
            ├── flags: newline
            ├── body:
               @ StatementsNode (location: (1,1)-(1,5))
               ├── flags: 
               └── body: (length: 1)
                   └── @ SymbolNode (location: (1,1)-(1,5))
                       ├── flags: newline, static_literal, forced_us_ascii_encoding
                       ├── opening_loc: (1,1)-(1,2) = "\""
                       ├── value_loc: (1,2)-(1,3) = "a"
                       ├── closing_loc: (1,3)-(1,5) = "\":"
                       └── unescaped: "a"
            ├── opening_loc: (1,0)-(1,1) = "("
            └── closing_loc: (1,5)-(1,6) = ")"

and ruby --parser=prism -e 'x = ("a":); p x' shows :a actually.

Bonus note

This bug is found by Lernen. Automata learning is real!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions