15
8
Fork
You've already forked zig-spec
2

Labeled block not allowed as lhs of assignment at statement level #4

Open
opened 2019年03月18日 15:54:00 +01:00 by Hejsil · 0 comments
Hejsil commented 2019年03月18日 15:54:00 +01:00 (Migrated from github.com)
Copy link

Explained here

Actually, this broke with the grammar changes in #1685. Basically, we have this rule at stmt level:

Statement
 <- ...
 / LabeledStatement
 ...
 / AssignExpr SEMICOLON
LabeledStatement <- BlockLabel? (Block / LoopStatement)

AssignExpr expands into all other expressions. LabeledStatement is before AssignExpr so that rule is being parsed first, succeeds and then Statement succeeds. Then the parser tries to end the __case_1 block, which then fails the parsing.

The parser parses the grammar correctly, but the new grammar just does not allow this syntax. I can't come up with a solution on top of my head right now.

Edit: Well, a solution would be to make translate-c conform to this new grammar. Idk if we want to put in the work to make x:{}.* = 1; valid at stmt level.

Explained [here](https://github.com/ziglang/zig/issues/2043#issuecomment-472900431) > Actually, this broke with the grammar changes in #1685. Basically, we have this rule at stmt level: > > ``` > Statement > <- ... > / LabeledStatement > ... > / AssignExpr SEMICOLON > > LabeledStatement <- BlockLabel? (Block / LoopStatement) > ``` > `AssignExpr` expands into all other expressions. `LabeledStatement` is before `AssignExpr` so that rule is being parsed first, succeeds and then `Statement` succeeds. Then the parser tries to end the `__case_1` block, which then fails the parsing. > > The parser parses the grammar correctly, but the new grammar just does not allow this syntax. I can't come up with a solution on top of my head right now. > > Edit: Well, a solution would be to make translate-c conform to this new grammar. Idk if we want to put in the work to make `x:{}.* = 1;` valid at stmt level.
alexrp unlocked this conversation 2025年12月13日 01:58:53 +01:00
Sign in to join this conversation.
No Branch/Tag specified
master
sync
disorganized-spec-chunks
No results found.
Labels
Clear labels
bounty
https://ziglang.org/news/announcing-donor-bounties
bug
Observed behavior contradicts documented or intended behavior.
contributor-friendly
This issue is limited in scope and/or knowledge of project internals.
downstream
An issue with a third-party project that uses this project.
enhancement
Solving this issue will likely involve adding new logic or components to the codebase.
infra
An issue related to project infrastructure, e.g. continuous integration.
optimization
A task to improve performance and/or resource usage.
question
No questions on the issue tracker; use a community space instead.
regression
Something that used to work in a previous version stopped working
upstream
An issue with a third-party project that this project uses.
use case
Describes a real use case that is difficult or impossible, but does not propose a solution.
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ziglang/zig-spec#4
Reference in a new issue
ziglang/zig-spec
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?