zig
zig copied to clipboard
Incorrect error message when assigning to a field in a struct definition
Zig Version
0.11.0-dev.3395+1e7dcaa3a
Steps to Reproduce and Observed Output
const S = struct {
foo: u32,
bar: u32,
baz = 5,
};
Output:
~ % zig build-obj test.zig
test.zig:2:5: error: tuple field has a name
foo: u32,
^~~
Expected Output
Caret should point to baz and the message should be more clear (if the foo and bar fields aren't present, the error message is use of undeclared identifier 'baz')
personally i would assume the error message to be that you're missing const or var on baz
That would work too - if we put a semicolon instead of a comma after baz the error is:
test.zig:4:12: error: expected ',' after field
baz = 5;
^
test.zig:4:5: note: use 'var' or 'const' to declare variable
baz = 5;
^~~
Duplicate of #14334.