-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorstage1The process of building from source via WebAssembly and the C backend.The process of building from source via WebAssembly and the C backend.
Milestone
Description
on 30 Jan 2020 with zig version 0.5.0+7ebc624a1 pulled and built from master last night.
In the following code, two @Vector(4, usize) are compared with == in the test scope with no problem. However if the same comparison is made within a struct fn, the == comparison results in:
error: expected type '@Vector(4, u64)', found '@Vector(4, usize)'It appears that the lhs @Vector(4, usize) is being converted to @Vector(4, u64) when it gets passed into a function. This error is not observed with u64 vector type.
//
// $ zig test repro.zig
// ./repro.zig:15:29: error: expected type '@Vector(4, u64)', found '@Vector(4, usize)'
// const eqs = self.limbs == other.limbs; // <--- here
// ^
// ./repro.zig:15:36: note: referenced here
// const eqs = self.limbs == other.limbs; // <--- here
// ^
//
test "repro: vector == with usize/isize" {
const S = struct {
limbs: @Vector(4, usize), // this error also occurs with isize
pub fn equals(self: @This(), other: @This()) bool {
// error: expected type '@Vector(1, u64)', found '@Vector(1, usize)'
const eqs = self.limbs == other.limbs; // <--- here
return true;
}
};
const s1 = S{ .limbs = @splat(4, @as(usize, 0)) };
const s2 = S{ .limbs = @splat(4, @as(usize, 0)) };
const eqs = s1.limbs == s2.limbs; // here == with usize vectors is ok
const eq = s1.equals(s2);
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorstage1The process of building from source via WebAssembly and the C backend.The process of building from source via WebAssembly and the C backend.