-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed as not planned
Closed as not planned
Copy link
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorerror messageThis issue points out an error message that is unhelpful and should be improved.This issue points out an error message that is unhelpful and should be improved.frontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.regressionIt worked in a previous version of Zig, but stopped working.It worked in a previous version of Zig, but stopped working.
Description
Zig Version
0.12.0-dev.3+9c05810be
Steps to Reproduce and Observed Behavior
const std = @import("std");
fn nothing() void {} // error is incorrectly displayed here
fn toSeeHere() void {}
fn resize(allocator: std.mem.Allocator, size: i32) !void {
const data = try allocator.alloc(u8, size); // error should be displayed here, alloc expects usize but we give it i32
defer allocator.free(data);
}
test "incorrect error location on integer cast" {
try resize(std.testing.allocator, 32);
}error:
src/main.zig:3:1: error: expected type 'usize', found 'i32'
fn nothing() void {} // error is incorrectly displayed here
^~~~~~~~~~~~~~~~~
src/main.zig:3:1: note: unsigned 64-bit int cannot represent all possible signed 32-bit values
referenced by:
test.incorrect error location on integer cast: src/main.zig:13:9
it mentions line 13, which is the call to resize, but it doesn't mention where in resize the error is.
It seems to always point the error at the first function in the file (that includes functions inside structs).
Expected Behavior
Show correct compile error location
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorerror messageThis issue points out an error message that is unhelpful and should be improved.This issue points out an error message that is unhelpful and should be improved.frontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.regressionIt worked in a previous version of Zig, but stopped working.It worked in a previous version of Zig, but stopped working.