Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
makenowjust opened this issue Sep 8, 2024 · 0 comments
Labels
bug Something isn't working invalid-syntax

Comments

@makenowjust
Copy link
Contributor

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!

@kddnewton kddnewton added bug Something isn't working invalid-syntax labels Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid-syntax
Projects
None yet
Development

No branches or pull requests

2 participants