[Issue 19538] New: "alias this" does not work with opEquals()

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jan 2 07:09:31 UTC 2019


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

          Issue ID: 19538
           Summary: "alias this" does not work with opEquals()
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: porton at narod.ru

This program does not compile. I think it should do.

---
struct X {
    string m;
    alias m this;
    bool opEquals(const X s) const {
        return true;
    }
}

void main() {
    X* x = new X("");
    assert(*x == "");
}
---

$ dmd --version
DMD64 D Compiler v2.080.1
Copyright (C) 1999-2018 by The D Language Foundation, All Rights Reserved
written by Walter Bright
$ dmd test.d
test.d(11): Error: function test.X.opEquals(const(X) s) const is not callable
using argument types (string)
test.d(11):        cannot pass argument "" of type string to parameter const(X)
s

--


More information about the Digitalmars-d-bugs mailing list