Closed
Description
π Search Terms
"control flow analysis", "never return"
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about
never
β― Playground Link
π» Code
class Class {
throwMethod(): never {
throw "bang";
}
}
function throwFunction(): never {
throw "bang";
}
function repro1(arg: string | undefined) {
if (!arg) {
new Class().throwMethod();
}
return arg.length;
}
function repro2(arg: string | undefined) {
if (!arg) {
throwFunction();
}
return arg.length;
}
π Actual behavior
When a class method has a never
return type (see repro1
function), the control flow analysis ignores this.
When a function method has a never
return type (see repro2
function), the control flow analysis correctly identifies that this execution branch will end.
π Expected behavior
I expected that the function and class method would be treated in the same way by the CFA, because I can't find an obvious reason why they should differ.
Additional information about the issue
No response
Metadata
Metadata
Assignees
Labels
No labels