Skip to content

Commit

Permalink
fix: type check error locations
Browse files Browse the repository at this point in the history
  • Loading branch information
sno2 committed Oct 31, 2024
1 parent 2af1c90 commit 7ffc958
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions playground/wasm.zig
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export fn codeGen(flavor: CodeGen.Flavor, is_program: bool) ?*CgInfo {
cg_info = .{
.error_ptr = output.items.ptr,
.error_len = output.items.len,
.start = cg.tokenizer.start,
.end = cg.tokenizer.index,
.start = cg.error_info.?.source_range.start,
.end = cg.error_info.?.source_range.end,
};
return &cg_info;
},
Expand Down
3 changes: 1 addition & 2 deletions src/CodeGen.zig
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ pub fn formatError(cg: *CodeGen, config: std.io.tty.Config, writer: anytype) !vo
try writer.writeByte('\'');
},
.expected_n_arguments => |data| {
try writer.writeByte('\'');
try writer.writeAll("function type '");
try cg.formatType(data.callee, writer);
try writer.print("' expects {} arguments, got {}", .{ data.expected, data.got });
},
Expand Down Expand Up @@ -662,7 +662,6 @@ fn genExpression(cg: *CodeGen, exe: *Executable, is_tail: bool, comptime is_type
cg.tokenizer.next();
const left_start = cg.tokenizer.start;
const left_type = try cg.genExpression(exe, false, is_typed);

if (is_typed and left_type != .num) {
try cg.fail(.{
.data = .{ .expected_type = .{ .expected = .num, .got = left_type } },
Expand Down

0 comments on commit 7ffc958

Please sign in to comment.