D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3267 - int delegate() should be implicitly castable to const(int) delegate()
Summary: int delegate() should be implicitly castable to const(int) delegate()
Status: RESOLVED DUPLICATE of issue 3180
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2009-08-27 07:10 UTC by Don
Modified: 2015-06-09 01:28 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 Don 2009-08-27 07:10:13 UTC
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 yebblies 2011-09-06 01:49:34 UTC

*** This issue has been marked as a duplicate of issue 3180 ***