Bug 9383 – Wrong context for contracts if closure [dis]appears in override function
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-01-24T00:24:00Z
Last change time
2017-07-22T12:35:59Z
Keywords
contracts, pull, wrong-code
Assigned to
nobody
Creator
verylonglogin.reg
Comments
Comment #0 by verylonglogin.reg — 2013-01-24T00:24:55Z
---
import std.stdio;
void delegate() del;
abstract class A
{
void f(int i)
in { writeln("A.f.in: i = ", i); }
body { } // no closure
void g(int i)
in { writeln("A.g.in: i = ", i); }
body { int x; del = { ++x; }; } // closure
}
final class B: A
{
override void f(int i)
in { writeln("B.f.in: i = ", i); }
body { int x; del = { ++x; }; } // closure appears
override void g(int i)
in { writeln("B.g.in: i = ", i); }
body { } // closure disappears
}
void main()
{
auto b = new B();
b.f(107);
b.g(108);
}
---
Output:
---
A.f.in: i = 909192741
A.g.in: i = 10428304
---
Also see Issue 6417.