make >> a compile error with any undef arg ; add a bunch of test cases
This commit is contained in:
@@ -196,10 +196,3 @@ test "Saturating Shift Left" {
|
||||
try expectEqual(170141183460469231731687303715884105727, S.shlSat(@as(i128, 0x2fe6bc5448c55ce18252e2c9d4477750), 0x31));
|
||||
try expectEqual(0, S.shlSat(@as(i128, 0), 127));
|
||||
}
|
||||
|
||||
test "shift by partially undef vector" {
|
||||
comptime {
|
||||
const a: @Vector(1, u8) = .{undefined};
|
||||
_ = a >> @splat(4);
|
||||
}
|
||||
}
|
||||
|
||||
11
test/cases/compile_errors/shl_exact_on_undefined_value.zig
Normal file
11
test/cases/compile_errors/shl_exact_on_undefined_value.zig
Normal file
@@ -0,0 +1,11 @@
|
||||
comptime {
|
||||
var a: i64 = undefined;
|
||||
var b: u6 = undefined;
|
||||
_ = &a;
|
||||
_ = &b;
|
||||
_ = @shlExact(a, b);
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :6:19: error: use of undefined value here causes illegal behavior
|
||||
11
test/cases/compile_errors/shl_on_undefined_value.zig
Normal file
11
test/cases/compile_errors/shl_on_undefined_value.zig
Normal file
@@ -0,0 +1,11 @@
|
||||
comptime {
|
||||
var a: i64 = undefined;
|
||||
var b: u6 = undefined;
|
||||
_ = &a;
|
||||
_ = &b;
|
||||
_ = a << b;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :6:9: error: use of undefined value here causes illegal behavior
|
||||
@@ -0,0 +1,11 @@
|
||||
comptime {
|
||||
var a: i64 = undefined;
|
||||
var b: u6 = undefined;
|
||||
_ = &a;
|
||||
_ = &b;
|
||||
_ = @shlWithOverflow(a, b);
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :6:26: error: use of undefined value here causes illegal behavior
|
||||
11
test/cases/compile_errors/shr_exact_on_undefined_value.zig
Normal file
11
test/cases/compile_errors/shr_exact_on_undefined_value.zig
Normal file
@@ -0,0 +1,11 @@
|
||||
comptime {
|
||||
var a: i64 = undefined;
|
||||
var b: u6 = undefined;
|
||||
_ = &a;
|
||||
_ = &b;
|
||||
_ = @shrExact(a, b);
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :6:19: error: use of undefined value here causes illegal behavior
|
||||
11
test/cases/compile_errors/shr_on_undefined_value.zig
Normal file
11
test/cases/compile_errors/shr_on_undefined_value.zig
Normal file
@@ -0,0 +1,11 @@
|
||||
comptime {
|
||||
var a: i64 = undefined;
|
||||
var b: u6 = undefined;
|
||||
_ = &a;
|
||||
_ = &b;
|
||||
_ = a >> b;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :6:9: error: use of undefined value here causes illegal behavior
|
||||
Reference in New Issue
Block a user