Add compile error when shifting amount is not an int type
This commit is contained in:
committed by
Andrew Kelley
parent
8e3c56b912
commit
866c253e0e
@@ -70,6 +70,26 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
"tmp.zig:6:37: error: expected type '*i32', found 'bool'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"shift amount has to be an integer type",
|
||||
\\export fn entry() void {
|
||||
\\ const x = 1 << &u8(10);
|
||||
\\}
|
||||
,
|
||||
"tmp.zig:2:23: error: shift amount has to be an integer type, but found '*u8'",
|
||||
"tmp.zig:2:17: note: referenced here",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"bit shifting only works on integer types",
|
||||
\\export fn entry() void {
|
||||
\\ const x = &u8(1) << 10;
|
||||
\\}
|
||||
,
|
||||
"tmp.zig:2:18: error: bit shifting operation expected integer type, found '*u8'",
|
||||
"tmp.zig:2:22: note: referenced here",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"struct depends on itself via optional field",
|
||||
\\const LhsExpr = struct {
|
||||
|
||||
Reference in New Issue
Block a user