Skip to content
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

std.builtin.SourceLocation.line - @src() is NOT a comptime value #17031

Closed
roig opened this issue Aug 31, 2023 · 1 comment
Closed

std.builtin.SourceLocation.line - @src() is NOT a comptime value #17031

roig opened this issue Aug 31, 2023 · 1 comment

Comments

@roig
Copy link
Contributor

roig commented Aug 31, 2023

Zig Version

0.11.0

Steps to Reproduce and Observed Behavior

This code should print the line correctly and it fails to compile:

const std = @import("std");

pub fn main() void {
    const line_text = comptime std.fmt.comptimePrint("{}", .{@src().line});
    std.debug.print(line_text, .{});
}
example.zig:4:61: error: unable to evaluate comptime expression
example.zig:4:61: note: operation is runtime due to this operand

This doesn't compile in 0.10 without -fstage1 and in 0.11.
This compiles correctly in 0.9 and in 0.10 with -fstage1.

Expected Behavior

Compile and print correctly the line number at runtime.

@roig roig added the bug Observed behavior contradicts documented or intended behavior label Aug 31, 2023
@ifreund
Copy link
Member

ifreund commented Aug 31, 2023

This is working as intended: #2029 (comment)

@ifreund ifreund closed this as not planned Won't fix, can't repro, duplicate, stale Aug 31, 2023
@ifreund ifreund removed the bug Observed behavior contradicts documented or intended behavior label Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants