Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
December 31, 2006 [Issue 780] New: The assignment of 'this' is allowed | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=780 Summary: The assignment of 'this' is allowed Product: D Version: 0.178 Platform: PC OS/Version: Windows Status: NEW Keywords: accepts-invalid Severity: major Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: brunodomedeiros+bugz@gmail.com The compiler allows assignment of the 'this' special reference. Instead 'this' should be final (i.e., non assignable). In some cases, like in a class constructor, 'this' is treated as if an inout reference, changing a variable in another scope: -------- -------- import std.stdio; class Foo { static bool first = true; this() { if(first){ first = false; this = new Foo(); writefln("this= ", cast(void *)this); } } } void main(char[][] args) { Foo foo = new Foo(); writefln("foo= ", cast(void *)foo); } -------- outputs: -------- this before= 8B0FE0 this after= 8B0FD0 foo= 8B0FD0 -- |
February 27, 2007 [Issue 780] The assignment of 'this' is allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=780 ------- Comment #1 from thomas-dloop@kuehne.cn 2007-02-27 10:47 ------- http://www.digitalmars.com/d/class.html#constructors # Constructors are defined with a function name of this and having no return value However the compiler implements class constructors as returning the this pointer # # module wood; # class Tree{ # this(){ # } # } # dmd -c wood.d && nm wood.o | grep _ctor | sed "s:.* ::" _D4wood4Tree5_ctorMFZC4wood4Tree demangled: wood.Tree wood.Tree.this(this) -- |
November 26, 2010 [Issue 780] The assignment of 'this' is allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=780 Andrei Alexandrescu <andrei@metalanguage.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED CC| |andrei@metalanguage.com AssignedTo|nobody@puremagic.com |bugzilla@digitalmars.com -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 08, 2011 [Issue 780] The assignment of 'this' is allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=780 --- Comment #2 from Andrei Alexandrescu <andrei@metalanguage.com> 2011-01-08 14:10:50 PST --- Before and after return the same thing in 2.051. Nevertheless, assigning to this should be syntactically disallowed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 22, 2012 [Issue 780] The assignment of 'this' is allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=780 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Platform|x86 |All Version|0.178 |D1 & D2 OS/Version|Windows |All Severity|major |normal --- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2012-01-22 13:40:09 PST --- The spec now disallows assignment to this and super, but the compiler still allows it. Since code like gtkd relies on allowing it, the progression should be: 1. spec change 2. make it a warning 3. deprecate it 4. remove from compiler This will take time. We're at (1). So the bug stays open for now. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 29, 2012 [Issue 780] The assignment of 'this' is allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=780 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jemandy@earthlink.net --- Comment #4 from yebblies <yebblies@gmail.com> 2012-01-29 22:44:26 EST --- *** Issue 4819 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 29, 2012 [Issue 780] The assignment of 'this' is allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=780 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |http://d.puremagic.com/issu | |es/show_bug.cgi?id=4596 --- Comment #5 from Kenji Hara <k.hara.pg@gmail.com> 2012-01-29 04:15:55 PST --- After fixing bug 4596, this will be an issue for only D1. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 30, 2012 [Issue 780] The assignment of 'this' is allowed | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=780 Denis Shelomovskij <verylonglogin.reg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |verylonglogin.reg@gmail.com Version|D1 & D2 |D1 --- Comment #6 from Denis Shelomovskij <verylonglogin.reg@gmail.com> 2012-10-30 16:29:54 MSK --- (In reply to comment #5) > After fixing bug 4596, this will be an issue for only D1. Bug 4596 is 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