[Issue 15984] [REG2.071] Interface contracts retrieve garbage instead of parameters

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Aug 31 21:45:26 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=15984

Thayne <astrothayne at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |astrothayne at gmail.com

--- Comment #7 from Thayne <astrothayne at gmail.com> ---
I still see this in dmd 2.071.1, and I see similar behavior for out contracts:

---
import std.stdio;
import std.conv;
import std.algorithm : canFind;

interface I {
    string foo(int input)
        in {
            writefln("In in, input = %s", input);
        }
        out (result) {
            writefln("In out, input = %s", input);
            writefln("Result = %s", result);
            assert(result.canFind(to!string(input)));
        }
}

class C : I {
    string foo(int input) in { assert(false); } body {
        writefln("Input = %s", input);
        return "Foo " ~ to!string(input);
    }
}

void main() {
    auto c = new C;

    c.foo(5);
}
---

--


More information about the Digitalmars-d-bugs mailing list