[Issue 17992] auto return type and null for classes

2020-03-20 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17992

Basile-z  changed:

   What|Removed |Added

 CC|b2.t...@gmx.com |

--


[Issue 17992] auto return type and null for classes

2019-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17992

Basile-z  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||b2.t...@gmx.com
 Resolution|--- |INVALID

--


[Issue 17992] auto return type and null for classes

2018-06-14 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17992

RazvanN  changed:

   What|Removed |Added

 CC||razvan.nitu1...@gmail.com

--- Comment #1 from RazvanN  ---
Reduced test case:

class V
{}

auto foo(int a)
{
if (a == 1)
return null;

pragma(msg, typeof(return));
return new V();
}

void main()
{}

prints: typeof(null)

I'm not sure if this bug is valid. When semantic analysis is performed at the
point where typeof is evaluated the inference of the return type of foo (in
both examples) has only seen return statements of null. This makes inference
deduce that the type of foo is typeof(null) and this is true for that
particular point.
Changing this would require moving the typeof logic from semantic1 to semantic2
or semantic3 so that when typeof is encountered, the whole foo function has
been typechecked.

--