-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Zig Version
0.10.0-dev.1463+5d943f621
Steps to Reproduce
An explicitly typed array initializer within an expression:
_ = -@Vector(4, i32){ 1, 2, 3, 4 };
Note that this still occurs with aliased types:
const i32x4 = std.meta.Vector(4, i32);
_ = i32x4{ 1, 2, 3, 4 } + i32x4{ 1, 2, 3, 4 };
Expected Behavior
Sema to receive type information to identify this array_init
as a vector_type
so the negation operator can be performed (as arrays cannot be negated, but vectors can).
Actual Behavior
Sema receives an array_init
ZIR instruction pointing to each member of the initializer, but the instruction does not point to the explicitly provided vector_type
, making Sema unable to determine if this list is allowed to negated. Instead, Sema will always infer that array_init
returns an array, which cannot be negated.
The current workaround is to move these initializers into intermediate variables to force them to get coerced into vectors before being used.