Bug 10534 – Addition and subtraction of delegates allowed
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-07-03T19:01:00Z
Last change time
2013-07-05T11:17:24Z
Keywords
accepts-invalid, pull
Assigned to
nobody
Creator
callumenator
Comments
Comment #0 by callumenator — 2013-07-03T19:01:39Z
DMD 2.063
void main()
{
int delegate() a = ()=>5;
int delegate() b = ()=>5;
auto c1 = a+b; // passes (and will crash if c1() called)
auto c2 = a-b; // passes (and will crash if c2() called)
auto c3 = a/b; // a & b not of arithmetic type
auto c4 = a*b; // a & b not of arithmetic type
}
DMD properly rejects all arithmetic if delegates are typed as int function()'s.