www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19538] New: "alias this" does not work with opEquals()

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 puremagic.com
          Reporter: porton 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

--
Jan 01