www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9383] New: Wrong context for contracts if closure [dis]appears in override function

http://d.puremagic.com/issues/show_bug.cgi?id=9383

           Summary: Wrong context for contracts if closure [dis]appears in
                    override function
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: wrong-code
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: verylonglogin.reg gmail.com


--- Comment #0 from Denis Shelomovskij <verylonglogin.reg gmail.com> 2013-01-24
11:24:55 MSK ---
---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 24 2013