authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-29 22:33:55-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-29 22:33:55-05:00
logf980c29306ac9435662bde6fb5557ca0c6d98310
tree1ba2e4587e93f53750cb6d01faf4e2c6c33788c0
parenta438a615e6e2ef9e49bf10405b3ba6c8814ccf4b
signaturelock-open Commit is signed but in an unrecognized format.

fix typo in error note for integer casting


2 files changed, 7 insertions(+), 1 deletions(-)

src/ir.cpp+1-1
......@@ -12753,7 +12753,7 @@ static void report_recursive_error(IrAnalyze *ira, AstNode *source_node, ConstCa
1275312753 ZigType *wanted_type = cast_result->data.int_shorten->wanted_type;
1275412754 ZigType *actual_type = cast_result->data.int_shorten->actual_type;
1275512755 const char *wanted_signed = wanted_type->data.integral.is_signed ? "signed" : "unsigned";
12756 const char *actual_signed = wanted_type->data.integral.is_signed ? "signed" : "unsigned";
12756 const char *actual_signed = actual_type->data.integral.is_signed ? "signed" : "unsigned";
1275712757 add_error_note(ira->codegen, parent_msg, source_node,
1275812758 buf_sprintf("%s %" PRIu32 "-bit int cannot represent all possible %s %" PRIu32 "-bit values",
1275912759 wanted_signed, wanted_type->data.integral.bit_count,
test/compile_errors.zig+6
......@@ -1644,11 +1644,17 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
16441644 \\ var spartan_count: u16 = 300;
16451645 \\ var byte: u8 = spartan_count;
16461646 \\}
1647 \\export fn entry4() void {
1648 \\ var signed: i8 = -1;
1649 \\ var unsigned: u64 = signed;
1650 \\}
16471651 ,
16481652 "tmp.zig:3:31: error: integer value 300 cannot be coerced to type 'u8'",
16491653 "tmp.zig:7:22: error: integer value 300 cannot be coerced to type 'u8'",
16501654 "tmp.zig:11:20: error: expected type 'u8', found 'u16'",
16511655 "tmp.zig:11:20: note: unsigned 8-bit int cannot represent all possible unsigned 16-bit values",
1656 "tmp.zig:15:25: error: expected type 'u64', found 'i8'",
1657 "tmp.zig:15:25: note: unsigned 64-bit int cannot represent all possible signed 8-bit values",
16521658 );
16531659
16541660 cases.add(