-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Open
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone
Description
Zig Version
0.14.1
Steps to Reproduce and Observed Behavior
The following minimal snippet reproduces the issue:
fn Fn(x: struct { []const u8, type }) type {
_ = x;
return struct {};
}
pub fn main() void {
var runtime_val: []const u8 = "true";
runtime_val = "false";
const T = Fn(.{ runtime_val, struct {} });
_ = T;
}
$ zig run problem.zig
Segmentation fault (core dumped)
Expected Behavior
Code should not compile, and return a helpful error message:
$ zig run problem.zig
problem.zig:9:18: error: unable to resolve comptime value
const T = Fn(.{ runtime_val, struct {} });
^~~~~~~~~~~~~~~~~~~~~~~
problem.zig:9:17: note: call to function with comptime-only return type 'type' is evaluated at comptime
const T = Fn(.{ runtime_val, struct {} });
~~^~~~~~~~~~~~~~~~~~~~~~
problem.zig:1:22: note: return type declared here
fn Fn(x: struct { []const u8, type }) type {
^~~~
problem.zig:9:17: note: types are not available at runtime
const T = Fn(.{ runtime_val, struct {} });
~~^~~~~~~~~~~~~~~~~~~~~~
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.