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

Missing void value expression checks #1729

Closed
enebo opened this issue Oct 23, 2023 · 7 comments
Closed

Missing void value expression checks #1729

enebo opened this issue Oct 23, 2023 · 7 comments
Labels
bug Something isn't working invalid-syntax

Comments

@enebo
Copy link
Collaborator

enebo commented Oct 23, 2023

or has a lower precedence than break/next/return.

break true or false
next true or false
return true or false
ruby -I. ./bin/parse -e 'return true or false'
@ ProgramNode (location: (1,0)-(1,20))
├── locals: []
└── statements:
    @ StatementsNode (location: (1,0)-(1,20))
    └── body: (length: 1)
        └── @ OrNode (location: (1,0)-(1,20))
            ├── left:
            │   @ ReturnNode (location: (1,0)-(1,11))
            │   ├── keyword_loc: (1,0)-(1,6) = "return"
            │   └── arguments:
            │       @ ArgumentsNode (location: (1,7)-(1,11))
            │       └── arguments: (length: 1)
            │           └── @ TrueNode (location: (1,7)-(1,11))
            ├── right:
            │   @ FalseNode (location: (1,15)-(1,20))
            └── operator_loc: (1,12)-(1,14) = "or"
@kddnewton kddnewton added the bug Something isn't working label Oct 23, 2023
@kddnewton
Copy link
Collaborator

It should though right?

@kddnewton kddnewton removed the bug Something isn't working label Oct 23, 2023
@kddnewton
Copy link
Collaborator

I think this is actually correct

@kddnewton
Copy link
Collaborator

It should error out with "void value expression" but I think the syntax tree is correct.

@enebo
Copy link
Collaborator Author

enebo commented Oct 23, 2023

yeah I guess so. So missing error.

@kddnewton kddnewton added bug Something isn't working invalid-syntax labels Oct 26, 2023
@makenowjust
Copy link
Contributor

Should "void value expression" be produced on parsing? Or, on compiling?

@kddnewton
Copy link
Collaborator

@makenowjust we've generally taken the approach of moving as much into parsing as possible so that all of the implementations can benefit. So for our case, I think it should be done while parsing.

@kddnewton kddnewton changed the title or has a lower precedence than break/next/return Missing void value expression checks Nov 12, 2023
@kddnewton
Copy link
Collaborator

Fixes by #1812

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

3 participants