D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 19538 - "alias this" does not work with opEquals()
Summary: "alias this" does not work with opEquals()
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P3 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-02 07:09 UTC by Victor Porton
Modified: 2024-12-13 19:01 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Victor Porton 2019-01-02 07:09:31 UTC
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
Comment 1 dlangBugzillaToGithub 2024-12-13 19:01:52 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19523

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB