make >> a compile error with any undef arg ; add a bunch of test cases

This commit is contained in:
Justus Klausecker
2025-08-07 02:08:40 +02:00
parent d0586da18e
commit 0ef26d113a
8 changed files with 65 additions and 32 deletions

View File

@@ -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);
}
}

View 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

View 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

View File

@@ -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

View 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

View 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