Merge pull request #6744 from LemonBoy/intcast-vec

stage1: Implement `@intCast` between vectors
This commit is contained in:
Andrew Kelley
2020-10-22 17:36:18 -04:00
committed by GitHub
7 changed files with 233 additions and 44 deletions

View File

@@ -2944,7 +2944,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
"tmp.zig:4:18: error: expected type 'fn(i32) void', found 'fn(bool) void",
"tmp.zig:4:18: note: parameter 0: 'bool' cannot cast into 'i32'",
});
cases.add("cast negative value to unsigned integer",
\\comptime {
\\ const value: i32 = -1;
@@ -2955,7 +2954,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\ const unsigned: u32 = value;
\\}
, &[_][]const u8{
"tmp.zig:3:36: error: cannot cast negative value -1 to unsigned integer type 'u32'",
"tmp.zig:3:22: error: attempt to cast negative value to unsigned integer",
"tmp.zig:7:27: error: cannot cast negative value -1 to unsigned integer type 'u32'",
});
@@ -2977,7 +2976,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\ var unsigned: u64 = signed;
\\}
, &[_][]const u8{
"tmp.zig:3:31: error: integer value 300 cannot be coerced to type 'u8'",
"tmp.zig:3:18: error: cast from 'u16' to 'u8' truncates bits",
"tmp.zig:7:22: error: integer value 300 cannot be coerced to type 'u8'",
"tmp.zig:11:20: error: expected type 'u8', found 'u16'",
"tmp.zig:11:20: note: unsigned 8-bit int cannot represent all possible unsigned 16-bit values",