[Issue 20866] New: Wrong overload function call with "scope const"

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 26 14:06:46 UTC 2020


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

          Issue ID: 20866
           Summary: Wrong overload function call with "scope const"
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: apz28 at hotmail.com

struct S
{
public:
    this(string s)
    {
        this.s = s;
    }

    // Remove 'const' will make it work
    void x(scope const S v)
    {
    }

    // Recursive calling itself because of alias value this - stack overflow
    private static int xCounter = 0;
    void x(string v)
    {
        assert(xCounter == 0);

        xCounter++;
        scope (exit)
            xCounter--;

        x(S(v));
    }

    @property string value()
    {
        return s;
    }

    alias value this;

private:
    string s;
}

void main()
{
    S s = S("a");
    s.x("b");
}

--


More information about the Digitalmars-d-bugs mailing list