Thread overview | |||||
---|---|---|---|---|---|
|
May 31, 2010 [Issue 4256] New: Inner template mathods can't access this pointer | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=4256 Summary: Inner template mathods can't access this pointer Product: D Version: unspecified Platform: x86 OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: simen.kjaras@gmail.com --- Comment #0 from Simen Kjaeraas <simen.kjaras@gmail.com> 2010-05-31 05:52:19 PDT --- struct bar { int n; void baz( ) { void qux(T)() { n = 3; } qux!int(); } } The above code barfs on 'n = 3;': "Error: need 'this' to access member n". -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 16, 2011 [Issue 4256] Inner template mathods can't access this pointer | ||||
---|---|---|---|---|
| ||||
Posted in reply to Simen Kjaeraas | http://d.puremagic.com/issues/show_bug.cgi?id=4256 Simen Kjaeraas <simen.kjaras@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code --- Comment #1 from Simen Kjaeraas <simen.kjaras@gmail.com> 2011-09-16 08:48:05 PDT --- This bug has grown worse. A lot worse. Good news: this now compiles: struct foo { int n; void baz( ) { void qux(T)() { n = 3; assert(n == 3); // Passes } qux!int(); } } void main( ) { foo b; assert(b.n == 0); // Passes b.baz(); assert(b.n == 3); // Fails } As we can see, the change in n is not properly propagated. What's even worse, is this: struct foo { int n; void baz( ) { void qux(T)(void* a) { // Added parameter n = 3; assert(n == 3); // Passes assert(a == &this); // Added. } qux!int(&this); } } void main( ) { foo b; assert(b.n == 0); // Passes b.baz(); assert(b.n == 3); // No longer fails. } You can then remove the assert on line 7 (a == &this) to get the old behavior back, the additional parameter changes nothing on its own. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 13, 2012 [Issue 4256] Inner template mathods can't access this pointer | ||||
---|---|---|---|---|
| ||||
Posted in reply to Simen Kjaeraas | http://d.puremagic.com/issues/show_bug.cgi?id=4256 Simen Kjaeraas <simen.kjaras@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |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