Bug 8308 – wrong function literal type inference results in type coercion

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-06-27T05:17:00Z
Last change time
2013-11-26T08:02:42Z
Assigned to
nobody
Creator
timon.gehr

Comments

Comment #0 by timon.gehr — 2012-06-27T05:17:17Z
DMD 2.059: void main(){ auto x = [x=>1.0, (long x)=>x][0]; // should be an error? double d = 1.0; assert(x(0)!=*cast(long*)&d); // (fails) }
Comment #1 by yebblies — 2013-11-26T08:02:42Z
Now correctly gives error: DMD v2.065 DEBUG testx.d(2): Error: cannot implicitly convert expression (__lambda1) of type double function(long x) pure nothrow @safe to long function(long x) pure nothrow @safe