Fix error reporting the wrong line for struct field inits (#13502)

* point to init part of field delc when that's where the error occurs

* update test to reflect fixed error message

* only lookup source location in case of error
This commit is contained in:
mparadinha
2022-11-15 13:17:23 +00:00
committed by Andrew Kelley
parent 2d623d7774
commit 35c13c262c
2 changed files with 59 additions and 11 deletions

View File

@@ -1,4 +1,6 @@
fn ignore(comptime param: anytype) void {_ = param;}
fn ignore(comptime param: anytype) void {
_ = param;
}
export fn foo() void {
const MyStruct = struct {
@@ -12,5 +14,5 @@ export fn foo() void {
// backend=stage2
// target=native
//
// :4:22: error: expected type '[]u8', found '*const [3:0]u8'
// :4:22: note: cast discards const qualifier
// :7:28: error: expected type '[]u8', found '*const [3:0]u8'
// :7:28: note: cast discards const qualifier