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

parser, checker: move more match validation into checker, add error for match without branches #21181

Merged
merged 5 commits into from
Apr 4, 2024

Conversation

ttytm
Copy link
Member

@ttytm ttytm commented Apr 3, 2024

Moves validation for match expression into the checker. We already do most of the related validation in the checker so the mantra "Parse, don't validate" might work especially well here.

The change includes adding an error for empty matches.
So instead of:

error: invalid expression: unexpected token `}`
    1 | match true {
    2 | }
      | ^

We'll get:

error: `match` must have at least two branches
    1 | match true {
      | ~~~~~
    2 | }

vlib/v/checker/match.v Outdated Show resolved Hide resolved
Co-authored-by: JalonSolov <JalonSolov@gmail.com>
@ttytm ttytm changed the title parser, checker: move more match validation into checker, add error for match without branchesl parser, checker: move more match validation into checker, add error for match without branches Apr 4, 2024
Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.

@spytheman spytheman merged commit ba577e4 into vlang:master Apr 4, 2024
54 checks passed
@ttytm ttytm deleted the checker/match-validation branch April 4, 2024 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants