Thread overview | |||||
---|---|---|---|---|---|
|
September 06, 2006 [Issue 325] New: Overriding members and overloading with alias causes bogus error messages in with(). | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=325 Summary: Overriding members and overloading with alias causes bogus error messages in with(). Product: D Version: unspecified Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: chris@dprogramming.com I finally was able to reproduce this problem with a small example: // Code begin class Base { private char[] myfoo; private char[] mybar; // Get/set properties that will be overridden. void foo(char[] s) { myfoo = s; } char[] foo() { return myfoo; } // Get/set properties that will not be overridden. void bar(char[] s) { mybar = s; } char[] bar() { return mybar; } } class Derived: Base { alias Base.foo foo; // Bring in Base's foo getter. override void foo(char[] s) { super.foo = s; } // Override foo setter. } void main() { Derived d; with(d = new Derived) { foo = "hi"; // Error! Due to the alias up there. d.foo = "hi"; // Works bar = "hi"; } } // Code end DMD 0.161 through 0.166 output: test.d(26): need 'this' to access member text I was able to find a workaround, simply put the alias after the function in the class instead of before. -- |
September 07, 2006 Re: [Issue 325] New: Overriding members and overloading with alias causes bogus error messages in with(). | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail Attachments: | d-bugmail@puremagic.com schrieb am 2006-09-06: > http://d.puremagic.com/issues/show_bug.cgi?id=325 > I finally was able to reproduce this problem with a small example: > > // Code begin > class Base > { > private char[] myfoo; > private char[] mybar; > > // Get/set properties that will be overridden. > void foo(char[] s) { myfoo = s; } > char[] foo() { return myfoo; } > > // Get/set properties that will not be overridden. > void bar(char[] s) { mybar = s; } > char[] bar() { return mybar; } > } > > class Derived: Base > { > alias Base.foo foo; // Bring in Base's foo getter. > override void foo(char[] s) { super.foo = s; } // Override foo setter. > } > > void main() > { > Derived d; > with(d = new Derived) > { > foo = "hi"; // Error! Due to the alias up there. > d.foo = "hi"; // Works > bar = "hi"; > } > } > // Code end > > DMD 0.161 through 0.166 output: test.d(26): need 'this' to access member text > > I was able to find a workaround, simply put the alias after the function in the class instead of before. Added to DStress as http://dstress.kuehne.cn/run/w/with_15_A.d http://dstress.kuehne.cn/run/w/with_15_B.d http://dstress.kuehne.cn/run/w/with_15_C.d http://dstress.kuehne.cn/run/w/with_15_D.d Thomas |
September 19, 2006 [Issue 325] Overriding members and overloading with alias causes bogus error messages in with(). | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=325 bugzilla@digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #2 from bugzilla@digitalmars.com 2006-09-19 15:28 ------- Fixed in DMC 0.167. -- |
Copyright © 1999-2021 by the D Language Foundation