Closed
Description
Analysis of uninitialized local fails to see initialization which happens after single-if without else.
Reproduce Code
foo: (x: bool) -> int = {
i: int;
if(x) {
i = 1;
return i;
}
i = 2;
return i;
}
main: () = foo(true);
Version
latest
Command line
cppfront/cppfront $1.cpp2 -p
clang++-15 -Icppfront/include $1.cpp -std=c++20 -o $1
Expected result
Compilation success
Actual result/error
initpath.cpp2(2,2): error: local variable i must be initialized on both branches or neither branch
initpath.cpp2(3,2): error: "if" initializes i on:
branch starting at line 3
but not on:
implicit else branch
Additional context
With return, both paths init and return.
Without return, there is double initialization, but error is the same.