Bug 3787 – clarification: assigment to 'this'

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-02-09T08:02:00Z
Last change time
2015-06-09T05:14:45Z
Keywords
spec
Assigned to
nobody
Creator
johannespfau

Attachments

IDFilenameSummaryContent-TypeSize
564testcase.dExample of assignment to thisapplication/octet-stream825

Comments

Comment #0 by johannespfau — 2010-02-09T08:02:26Z
Created attachment 564 Example of assignment to this Assigning to 'this' is currently not documented anywhere. Still assigning to this, at least in constructors, works and is used by some code (gtkd, for example). I think assigning to this should either work in constructors as it does right now, but it then should be documented, or it should be disallowed. If it will stay implementation specific, that should still be noted in the docs. see also: http://d.puremagic.com/issues/show_bug.cgi?id=780 The assignment of 'this' is allowed
Comment #1 by andrei — 2010-02-09T08:42:34Z
This doesn't look major.
Comment #2 by johannespfau — 2010-02-09T10:54:37Z
I just thought if you'd disallow assignment to this completely as the poster in bug 780 suggests, you might want to discuss that in the newsgroup. As this is quite late for d2 I flagged it major. Also I think completely undocumented and undefined features being already used in production code (gtkd) is a bad thing. However, I hadn't seen the bugzilla fields explanation, sorry. I'll change the priority. Btw, what is most likely to happen in the end? 1: make current behavior part of specification 2: disallow assignment to this completely 3: leave this as implementation specific behavior
Comment #3 by bugzilla — 2012-01-22T13:34:48Z
Assignment to this and super should not be allowed. The gtkd code can be fixed by making a 'factory' method to create a new object. However, this is not a trivial fix, and so having the compiler disallow the current code should be a long time in coming. In the meantime, I've updated the spec.
Comment #4 by github-bugzilla — 2012-01-22T13:35:35Z