-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
stage2: Inferring the type of chained ifs differ in behavior between stage1 and 2 #11969
Copy link
Copy link
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.10.0-dev.2803+c248af3bd
Steps to Reproduce
// test.zig
const std = @import("std");
const testing = std.testing;
test {
var a = false;
var b = false;
const name = if (a)
"ab"
else if (b)
return error.TestFailed
else
null;
try testing.expect(name == null);
}$ stage1/zig test test.zig
$ stage2/zig test test.zig
Expected Behavior
I would expect the stage2 compiler to figure this out in the same way, stage1 does.
Actual Behavior
$ stage2/zig test test.zig
test.zig:10:10: error: value with comptime only type '@TypeOf(null)' depends on runtime control flow
else if (b)
^
test.zig:10:14: note: runtime control flow here
else if (b)
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.