Bug 11207 – improve implicit conversions of function pointers/delegates

Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-10-09T08:03:00Z
Last change time
2013-10-10T06:51:00Z
Assigned to
nobody
Creator
eberhardhoepfner

Comments

Comment #0 by eberhardhoepfner — 2013-10-09T08:03:07Z
class A {} class B : A {} B foo(const A) { return null; } void main() { A function(const A) f1 = &foo; // compiles B function(A) f2 = &foo; // does not compile B function(immutable A) f3 = &foo; // does not compile B function(B) f4 = &foo; // does not compile } test.d(6): Error: cannot implicitly convert expression (& foo) of type B function(const(A) _param_0) to B function(A) test.d(7): Error: cannot implicitly convert expression (& foo) of type B function(const(A) _param_0) to B function(immutable(A)) test.d(8): Error: cannot implicitly convert expression (& foo) of type B function(const(A) _param_0) to B function(B) These implicit conversions should be possible. Explicit casting is too confusing and dangerous. If you make a mistake, you will end up with serious runtime errors.
Comment #1 by andrej.mitrovich — 2013-10-10T06:51:00Z
*** This issue has been marked as a duplicate of issue 7725 ***