Bug 14846 – Insufficient context deduction with implicit nested lambda
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-07-29T04:46:00Z
Last change time
2017-07-22T12:36:18Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
k.hara.pg
Comments
Comment #0 by k.hara.pg — 2015-07-29T04:46:27Z
Test case:
void foo(Dg)(scope Dg code)
{
pragma(msg, Dg);
// Now Dg is deduced to 'void function()',
// but it should be 'void delegate()'.
code();
}
void main()
{
int x;
struct S
{
this(int n) { x = n; }
~this() { x = 99; }
}
foo({ S s; });
foo({ S s = S(); });
foo({ S s = S(1); });
foo({ S[3] s; });
foo({ S* p = new S(); });
foo({ S* p = new S(1); });
foo({ S[] a = [S()]; });
foo({ S[] a = [S(1)]; });
}