D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7525 - [2.058 regression] Broken return type inference for delegate returns
Summary: [2.058 regression] Broken return type inference for delegate returns
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 regression
Assignee: No Owner
URL:
Keywords: pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2012-02-16 14:33 UTC by siegelords_abode
Modified: 2012-02-27 10:52 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description siegelords_abode 2012-02-16 14:33:26 UTC
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 siegelords_abode 2012-02-22 13:59:01 UTC
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.
Comment 3 github-bugzilla 2012-02-26 21:37:19 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/53b1a0461b485c1260514094e2164bd749f3f6d0
Merge pull request #765 from 9rnsr/fix7525

[2.058 regression] Issue 7525 - Broken return type inference for delegate returns