AstGen: fix src loc for invalid coercions in tuple literals

This commit is contained in:
Jacob Young
2023-08-11 22:45:55 -04:00
parent ffc116de78
commit 2b5bd56a67
2 changed files with 26 additions and 1 deletions

View File

@@ -0,0 +1,22 @@
export fn invalidArrayElem() u8 {
const array_literal = [1]u8{@as(u8, 256)};
return array_literal[0];
}
export fn invalidTupleElem() u8 {
const tuple_literal = struct { u8 }{@as(u8, 256)};
return tuple_literal[0];
}
export fn invalidStructField() u8 {
const struct_literal = struct { field: u8 }{ .field = @as(u8, 256) };
return struct_literal.field;
}
// error
// backend=stage2
// target=native
//
// :2:41: error: type 'u8' cannot represent integer value '256'
// :7:49: error: type 'u8' cannot represent integer value '256'
// :12:67: error: type 'u8' cannot represent integer value '256'