-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior
Description
Zig Version
0.11.0-dev.2168+322ace70f
Steps to Reproduce and Observed Behavior
This is the following minimum reproduction case I could determine for this:
const HelperReturnType = @typeInfo(@TypeOf(helper)).Fn.return_type.?;
pub fn concat() HelperReturnType {
return "";
}
fn helper(comptime string: []const u8) ![]const u8 {
return string ++ " world!";
}
test {
_ = try concat();
}The following compile error is observed on invocation of zig test repro.zig:
repro.zig:8:12: error: unable to resolve comptime value
return string ++ " world!";
^~~~~~
repro.zig:8:12: note: slice value being concatenated must be comptime-known
It is worth noting that helper doesn't need to be called for this to happen, and that using @typeInfo to get the error set for helper and use it as part of an error union for concat's return value also exhibits this behaviour.
Making helper an inline fn allows the program to compile successfully, as does removing the concat invocation. Writing _ = HelperReturnType without a concat invocation does not reproduce the error.
Expected Behavior
The code should have compiled successfully.
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavior