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

--- Comment #21 from anonymous4 <dfj1es...@sneakemail.com> ---
Nice progress. New test case:
---
struct A
{
    void delegate() a;
    int b;
    void f(){ a=&g; }
    void g(){ b++; }
    int h() const { a(); return b; }
}

void f(ref const A a)
{
    const int b1=a.h, b2=a.h;
    assert(b1==b2,"changed");
}

unittest
{
    A a;
    a.f();
    f(a);
}
---

Though issue 16058 allows one to design API that enforces correctness:

void f(void delegate() const a);
unittest
{
    A a;
    f(&a.g);
}
Error: cannot pass argument &a.g of type void delegate() to parameter void
delegate() const a

--

Reply via email to