-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Regression with "Unable to evaluate constant expression" in len of fixed size arrays #15280
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
Comments
Probably caused by #14819 |
Possibly related to #12240 |
Yes caused by that and yes related to that - it happens when you have another layer of field access before const S = struct {
arr: [5]u8 = undefined,
};
var x: S = .{};
comptime {
_ = x.arr.len;
} Because function-level |
Related to 34e4b07. This makes `struct.arr.len` succeed at comptime. Resolves: ziglang#15280
Related to 34e4b07. This makes `struct.arr.len` succeed at comptime. Resolves: ziglang#15280
Related to 34e4b07. This makes `struct.arr.len` succeed at comptime. Resolves: ziglang#15280
Workaround: comptime {
// broken
_ = s.arr.len;
// works
_ = @typeInfo(std.meta.FieldType(@TypeOf(s), .arr)).Array.len;
} Would love to see this fixed, rooting for #15287. |
This can be closed. |
Zig Version
0.11.0-dev.2571+31738de28
Steps to Reproduce and Observed Behavior
Run
zig build-exe repro.zig
:hasher.buf.len
is comptime known because it is a fixed size array and therefore can be determined by the type definition of theWyhash
struct'sbuf
field.Similarly, this fails to compile:
Expected Behavior
Compile successfully
This worked until at least
0.11.0-dev.2371+a31450375
, which means it is a regression.The text was updated successfully, but these errors were encountered: