| author | |
| committer | |
| log | f980c29306ac9435662bde6fb5557ca0c6d98310 |
| tree | 1ba2e4587e93f53750cb6d01faf4e2c6c33788c0 |
| parent | a438a615e6e2ef9e49bf10405b3ba6c8814ccf4b |
| signature |
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 |
| 12753 | 12753 | ZigType *wanted_type = cast_result->data.int_shorten->wanted_type; |
| 12754 | 12754 | ZigType *actual_type = cast_result->data.int_shorten->actual_type; |
| 12755 | 12755 | 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"; | |
| 12757 | 12757 | add_error_note(ira->codegen, parent_msg, source_node, |
| 12758 | 12758 | buf_sprintf("%s %" PRIu32 "-bit int cannot represent all possible %s %" PRIu32 "-bit values", |
| 12759 | 12759 | wanted_signed, wanted_type->data.integral.bit_count, |
test/compile_errors.zig+6| ... | ... | @@ -1644,11 +1644,17 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 1644 | 1644 | \\ var spartan_count: u16 = 300; |
| 1645 | 1645 | \\ var byte: u8 = spartan_count; |
| 1646 | 1646 | \\} |
| 1647 | \\export fn entry4() void { | |
| 1648 | \\ var signed: i8 = -1; | |
| 1649 | \\ var unsigned: u64 = signed; | |
| 1650 | \\} | |
| 1647 | 1651 | , |
| 1648 | 1652 | "tmp.zig:3:31: error: integer value 300 cannot be coerced to type 'u8'", |
| 1649 | 1653 | "tmp.zig:7:22: error: integer value 300 cannot be coerced to type 'u8'", |
| 1650 | 1654 | "tmp.zig:11:20: error: expected type 'u8', found 'u16'", |
| 1651 | 1655 | "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", | |
| 1652 | 1658 | ); |
| 1653 | 1659 | |
| 1654 | 1660 | cases.add( |