https://issues.dlang.org/show_bug.cgi?id=16194
Issue ID: 16194
Summary: auto return type inference depends on return statement
order
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
void main()
{
fun1(2); // Error: mismatched function return type inference
fun2(2); // OK
}
class A {}
class B : A {}
class C : A {}
auto fun1(int a)
{
if (a < 3)
return new B();
else if (a < 5)
return new C();
else
return new A();
}
auto fun2(int a)
{
if (a < 3)
return new A();
else if (a < 5)
return new B();
else
return new C();
}
--