Bug 3267 – int delegate() should be implicitly castable to const(int) delegate()

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2009-08-27T07:10:00Z
Last change time
2015-06-09T01:28:06Z
Keywords
rejects-valid
Assigned to
nobody
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2009-08-27T07:10:13Z
Test case: --- void foo(const int x) { int delegate(int t) bar = (int t){ return x; }; } ------ bug.d(3): Error: cannot implicitly convert expression (__dgliteral1) of type c onst(int) delegate(int t) to int delegate(int t) ---- // But this one works.... void foo(const int x) { int delegate(int t) bar = (int t){ return x+0; }; } I think the reason for this is that TypeDelegate::implicitConvTo() is not defined. It should allow implicit conversions of return value between type const(T), immutable(T), and type T, when T is a value type. Certainly for delegate literals.
Comment #1 by yebblies — 2011-09-06T01:49:34Z
*** This issue has been marked as a duplicate of issue 3180 ***