Thread overview | ||||||
---|---|---|---|---|---|---|
|
January 10, 2010 [Issue 3694] New: Template this parameters don't work with operator overloads | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=3694 Summary: Template this parameters don't work with operator overloads Product: D Version: 2.036 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: tomeksowi@gmail.com --- Comment #0 from Tomasz Sowiński <tomeksowi@gmail.com> 2010-01-10 15:07:37 PST --- Testcase: class A { int a; This opAssign(this This)(int a) { this.a = a; return this; } } void main() { A aa = new A; aa = 4; // oops! } Error: template test.A.opAssign(this This) does not match any function template declaration Error: template test.A.opAssign(this This) cannot deduce template function from argument types !()(int) ----------------------------------------------- The testcase should compile. Problem is that when operator overloads are used, template this parameters are not inferred. I suspect it's like that for all operator overloads (I tested only for assign and add, though). When you call the operator functions explicitly, aa.opAssign(4), it compiles. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 05, 2010 [Issue 3694] Template this parameters don't work with operator overloads | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tomasz Sowiński | http://d.puremagic.com/issues/show_bug.cgi?id=3694 gareth.charnock@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |gareth.charnock@gmail.com --- Comment #1 from gareth.charnock@gmail.com 2010-03-04 16:23:09 PST --- I can confirm this bug is still present in DMD 2.040. Test case used: struct ddouble(int l,int m /*other SI dimensions would go here*/) { this(double _val) {val=val;} ddouble!(l+l2,m+m2) opMult(int l2,int m2)(ddouble!(l2,m2) oprand) { return ddouble!(l+l2,m+m2)(val*oprand.val); } ddouble!(l+l2,m+m2) mult(int l2,int m2)(ddouble!(l2,m2) oprand) { return ddouble!(l+l2,m+m2)(val*oprand.val); } /* /,-,+ operators would go here */ double val; }; void main() { ddouble!(1,0) length=ddouble!(1,0)(1.0); ddouble!(0,1) mass =ddouble!(0,1)(1.0); auto t2=length.mult(mass); //Works auto t3=length*mass; //Error } testcase.d(28): Error: incompatible types for ((length) * (mass)): 'ddouble!(1,0)' and 'ddouble!(0,1)' -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 08, 2010 [Issue 3694] Template this parameters don't work with operator overloads | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tomasz Sowiński | http://d.puremagic.com/issues/show_bug.cgi?id=3694 --- Comment #2 from gareth.charnock@gmail.com 2010-03-08 13:30:49 PST --- Bug appears to be fixed in DMD 2.041. Both test cases compile fine now. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 13, 2010 [Issue 3694] Template this parameters don't work with operator overloads | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tomasz Sowiński | http://d.puremagic.com/issues/show_bug.cgi?id=3694 Tomasz Sowiński <tomeksowi@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #3 from Tomasz Sowiński <tomeksowi@gmail.com> 2010-03-13 03:53:06 PST --- (In reply to comment #2) > Bug appears to be fixed in DMD 2.041. Both test cases compile fine now. Also works here. I'm marking as fixed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation