D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5068 - opOpAssign fails when if()-constraint is used
Summary: opOpAssign fails when if()-constraint is used
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2010-10-17 00:27 UTC by Nick Sabalausky
Modified: 2010-10-17 00:35 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 Nick Sabalausky 2010-10-17 00:27:26 UTC
class Foo
{
	Foo opOpAssign(string op)(Foo b) if(op=="~=")
	{
		return this;
	}
}
void main()
{
	Foo f = new Foo();
	
	// Error: cannot append type test.Foo to type test.Foo
	f ~= new Foo();
}
Comment 1 Nick Sabalausky 2010-10-17 00:34:43 UTC
Nevermind, I apparently can't read the docs right. This is how it's supposed to be, and it does work right:

Foo opOpAssign(string op)(Foo b) if(op=="~")