-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Compiler error using array concatenation with inferred types #4417
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
Duplicate of #3979! |
Thanks. Closing this one. Will add the more complex test case to the original. |
This was initially closed as a duplicate, but #3979 didn't fix all the cases above this when it was closed. I didn't find another open issue that covered these. Shorter example with just the lines that aren't working: const StructWithDefault = struct {
value: f32 = 42,
};
const SomeStruct = struct {
array: [4]StructWithDefault,
};
pub fn main() void {
// error #1
const value3 = SomeStruct{ .array = .{StructWithDefault{}} ++ [_]StructWithDefault{undefined} ** 3 };
// error #2
const value4 = SomeStruct{ .array = .{.{}} ++ [_]StructWithDefault{undefined} ** 3 };
} error 1
error 2
Both errors can be worked around by adding the array type first: Zig version: 0.9.0-dev.70+a3f7a48d9 |
not sure if this is in scope for type inference |
Closes ziglang#4144 Closes ziglang#4255 Closes ziglang#4372 Closes ziglang#4375 Closes ziglang#4380 Closes ziglang#4417 Closes ziglang#4423 Closes ziglang#4476 Closes ziglang#4528 Closes ziglang#4562 Closes ziglang#4572 Closes ziglang#4597 Closes ziglang#4639 Closes ziglang#4672 Closes ziglang#4782 Closes ziglang#4955 Closes ziglang#4984 Closes ziglang#4997 Closes ziglang#5010 Closes ziglang#5114 Closes ziglang#5166 Closes ziglang#5173 Closes ziglang#5276
Closes ziglang#4144 Closes ziglang#4255 Closes ziglang#4372 Closes ziglang#4375 Closes ziglang#4380 Closes ziglang#4417 Closes ziglang#4423 Closes ziglang#4476 Closes ziglang#4528 Closes ziglang#4562 Closes ziglang#4572 Closes ziglang#4597 Closes ziglang#4639 Closes ziglang#4672 Closes ziglang#4782 Closes ziglang#4955 Closes ziglang#4984 Closes ziglang#4997 Closes ziglang#5010 Closes ziglang#5114 Closes ziglang#5166 Closes ziglang#5173 Closes ziglang#5276
Closes ziglang#4144 Closes ziglang#4255 Closes ziglang#4372 Closes ziglang#4375 Closes ziglang#4380 Closes ziglang#4417 Closes ziglang#4423 Closes ziglang#4476 Closes ziglang#4528 Closes ziglang#4562 Closes ziglang#4572 Closes ziglang#4597 Closes ziglang#4639 Closes ziglang#4672 Closes ziglang#4782 Closes ziglang#4955 Closes ziglang#4984 Closes ziglang#4997 Closes ziglang#5010 Closes ziglang#5114 Closes ziglang#5166 Closes ziglang#5173 Closes ziglang#5276
Minimal test. Printed error: assertion failed. This is a bug in the Zig compiler.
I am not 100% sure if the second line is supposed to be compilable, but minimally needs some sort of compiler error.
But assuming the compiler_bug line is correct, then below I added some slightly more complex test cases that would make sense if they worked as well:
My actual use case involves serializing an inline array (fixed max length, variable number of elements)
to zig code where I only want to define the elements that are actually populated and leave the rest undefined. Explicitly defining the array type like in
Ok #1
let me workaround this for now.0.5.0+b55bc5e
The text was updated successfully, but these errors were encountered: