D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 10263 - Refused class opBinary by ref
Summary: Refused class opBinary by ref
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords: diagnostic, rejects-valid
Depends on:
Blocks:
 
Reported: 2013-06-04 04:55 UTC by bearophile_hugs
Modified: 2024-12-13 18:07 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 bearophile_hugs 2013-06-04 04:55:45 UTC
class Foo {
    Foo opBinary(string op)(ref Foo) {
        return null;
    }
}
void main() {
    auto f = new Foo;
    auto r1 = f * f;         // OK
    auto r2 = f * (new Foo); // Error.
}



DMD 2.064alpha gives:

test.d(9): Error: 'f' is not of arithmetic type, it is a test.Foo
test.d(9): Error: 'new Foo' is not of arithmetic type, it is a test.Foo


I think that's a bug. Even if that's not a bug, then I suggest to improve the error messages.
Comment 1 dlangBugzillaToGithub 2024-12-13 18:07:35 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

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

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