-
-
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 behaviorfrontendTokenization, 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.
Milestone
Description
Zig Version
0.10.0-dev.4333+f5f28e0d2
Steps to Reproduce
const std = @import("std");
inline fn setLimits(min: ?u32, max: ?u32) void {
if (min != null and max != null) {
std.debug.assert(min.? <= max.?);
}
}
pub fn main() void {
var x: u32 = 42;
setLimits(x, null);
}(Sorry its not a test because my test was broken with this build thats fixed later)
Other notes:
inlineis required. Ifinlineis removed, this issue does not reproduce.- Two args required (at least). When I removed one arg, this issue did not reproduce.
- Runtime argument is required for one of the args. If both are comptime, this evaluates correctly.
Expected Behavior
Should compile.
Actual Behavior
$ zig run test.zig
test.zig:5:38: error: unable to unwrap null
std.debug.assert(min.? <= max.?);
~~~^~
test.zig:11:14: note: called from here
setLimits(x, null);
~~~~~~~~~^~~~~~~~~
(Note: -fstage1 works fine)
Reactions are currently unavailable
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.regressionIt worked in a previous version of Zig, but stopped working.It worked in a previous version of Zig, but stopped working.