-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Open
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior
Description
Zig Version
0.15.0-dev.1021+43fba5ea8
Steps to Reproduce and Observed Behavior
Each of the following declarations should cause ast-check errors due to the corresponding label not being found:
const A = struct {
a: while (true) // used as container field name
({
break :a usize;
}),
};
const b: while (true) // used as an identifier
({
break :b bool;
}) = false;
extern fn c(d: while (true) // used as an identifier
({
break :d u64;
})) void;
// The following are not semantically valid, however they
// are valid AST's and therefore affect zig fmt.
const F = *align(.g: { // used as an align
break :g 10;
}: 0)u8; // (and other bit pointer colons)
const H = [.i: { // used as an array length
break :i 0;
}]u8;
however they don't. Each IDENTIFIER COLON
is treated as both their correct use and as a label. This is not allowed because the language's grammar is specified as a PEG (see the Grammar section of the langref) which is unambiguous on how these are interpreted (each token can only belong to one thing).
They are additionally wrongly formatted by zig fmt
due to the same issue (each IDENTIFIER COLON
gets duplicated).
Expected Behavior
I except the corresponding errors to be emitted, and for zig fmt
to not duplicate the labels.
rohlemNoReligion
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior