-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compiler error message for calling std.debug.print with the wrong format string doesn't include the line number of the error, even when compiling with -freference-trace #19158
Comments
The error trace does say where it comes from, strange that it says its with the segfault handling.
|
i saw this happen to someone the other day where it points at the segfault handler, i have no idea why thats happening but im pretty sure its fairly recent |
looks similar to #18900 to me |
@rohlem That one occurs by calling logging methods, this is occurring in the stack trace printing code in std. |
@RossComputerGuy Right, and as far as I can see both cases trigger the |
Proposed a solution in #20292 : tweak |
This is probably caused by #18900 |
Running the sample program with ❯ zig run src/main.zig -freference-trace
/home/lillis/zig/lib/std/fmt.zig:483:5: error: invalid format string 's' for type 'i32'
@compileError("invalid format string '" ++ fmt ++ "' for type '" ++ @typeName(@TypeOf(value)) ++ "'");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
referenced by:
formatIntValue__anon_8891: /home/lillis/zig/lib/std/fmt.zig:765:24
formatValue__anon_8614: /home/lillis/zig/lib/std/fmt.zig:717:52
formatType__anon_8478: /home/lillis/zig/lib/std/fmt.zig:511:31
format__anon_7837: /home/lillis/zig/lib/std/fmt.zig:188:23
print__anon_3748: /home/lillis/zig/lib/std/io/Writer.zig:24:26
print__anon_3343: /home/lillis/zig/lib/std/io.zig:324:47
main: src/main.zig:5:20
posixCallMainAndExit: /home/lillis/zig/lib/std/start.zig:523:22
_start: /home/lillis/zig/lib/std/start.zig:361:40
comptime_0: /home/lillis/zig/lib/std/start.zig:99:54 |
thanks ! |
const std = @import("std");
pub fn main() void {
const myconst : i32 = 42;
std.debug.print("Hello {d}\n", .{myconst});
} 你应该使用 {d}, 这是一个int !!! |
Zig Version
0.12.0-dev.3126+136d7c213
Steps to Reproduce and Observed Output
Zig Version
0.12.0-dev
Steps to Reproduce and Observed Output
When you call std.debug.print with too few arguments:
The error message doesn't include the line number, even when compiling with -freference-trace
In #18485 , which looks very similar, @xdBronch says that is fixed in master, and I'm on the latest version, AFAIK.
Command line
zig run main.zig -freference-trace
Output
Notice how nowhere in this output is the actual source line in my own code specified.
Note: I'm new to zig (just started learning today), so I might be misunderstanding something.
Expected Output
I'd expect the error message to include the line number of the offending statement.
The text was updated successfully, but these errors were encountered: