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

Grammar allows for operations preceding break/continue keywords #55

Open
connorjclark opened this issue Sep 4, 2024 · 0 comments
Open

Comments

@connorjclark
Copy link

while (true) {
    !break;
}

while (true) {
    --break;
}

while (true) {
    1 + break;
}

All three pass the grammar as defined in grammar.y, and I believe the first two have no impact on actual zig compilation results. The third one fails the zig compiler due to unreachable code (it considers the 1 + to be unreachable)

PrimaryExpr is the relevant rule. All of the binary and unary operations coming in from PrefixExpr on the left-hand-side is what allows for this unexpected grammar.

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

No branches or pull requests

1 participant