Bug 7525 – [2.058 regression] Broken return type inference for delegate returns
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-02-16T14:33:00Z
Last change time
2012-02-27T10:52:23Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
siegelords_abode
Comments
Comment #0 by siegelords_abode — 2012-02-16T14:33:26Z
This worked in DMD 2.057, but doesn't compile in 2.058:
void main()
{
int a;
char[] delegate() b = { a = 0; return null;};
}
Error is:
test.d(4): Error: cannot implicitly convert expression (__lambda1) of type typeof(null) delegate() nothrow @safe to char[] delegate()
Comment #1 by siegelords_abode — 2012-02-22T13:59:01Z
A few more examples that don't work in 2.058 but work in 2.057:
int delegate() a = {return 1U;};
uint delegate() b = {return 1;};
float delegate() c = {return 1.0;};
double delegate() d = {return 1.0f;};
Note that both compilers allow implicit conversions between those basic type pairs.