D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 8663 - AliasThis is not used in comparison
Summary: AliasThis is not used in comparison
Status: RESOLVED DUPLICATE of issue 5380
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-15 04:48 UTC by Robik
Modified: 2022-09-08 09:11 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Robik 2012-09-15 04:48:04 UTC
Demo: http://dpaste.dzfl.pl/72015697

Test case:
import std.stdio;

void main()
{
	C c = new C("foo");	
	writeln(c == "foo");
}

class C
{
	string v;
	
	// This does not work
	alias v this;
	
	this(string val) { v = val; }
}

Result:
testcase.d(8): Error: function object.Object.opEquals (Object lhs, Object rhs) is not callable using argument types (string)
testcase.d(8): Error: expected 2 function arguments, not 1
Comment 1 Robik 2012-09-15 07:12:21 UTC
Also concerns opCmp.
Comment 2 yebblies 2013-01-01 23:15:23 UTC
This is a dmd issue.  Assigning to the alias this expert.
Comment 3 Walter Bright 2018-11-19 11:05:57 UTC
https://github.com/dlang/dmd/pull/8976
Comment 4 Walter Bright 2018-11-19 11:07:18 UTC
This is another facet of https://issues.dlang.org/show_bug.cgi?id=5380

I'm not sure we should be 'fixing' this.
Comment 5 RazvanN 2022-09-08 09:11:15 UTC

*** This issue has been marked as a duplicate of issue 5380 ***