Bug 13130 – Syntax check fails when this is used as argument type

Status
RESOLVED
Resolution
WONTFIX
Severity
minor
Priority
P1
Component
visuald
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2014-07-14T10:41:55Z
Last change time
2018-05-12T14:27:27Z
Assigned to
No Owner
Creator
Benjamin Thaut
See also
https://issues.dlang.org/show_bug.cgi?id=12228

Comments

Comment #0 by code — 2014-07-14T10:41:55Z
The following class causes the VisualD syntax checker to highlight the constructor as syntactically incorrect although it is syntactically correct and compiles just fine. class Foo { public: this(this other) { } }
Comment #1 by r.sagitario — 2014-07-18T10:00:10Z
I remember having seen this syntax before, but do you have a link to it being mentioned in the language spec? I have found postblit only, but that does not come with an identifier. I guess you are using DParser as the semantic engine (though probably the other engine doesn't accept it, too).
Comment #2 by hsteoh — 2014-07-19T01:13:30Z
Shouldn't that be: this(typeof(this) other) { ... } ? Is this a case of accepts-invalid?
Comment #3 by code — 2014-07-24T17:36:45Z
I did actually read about this syntax on the newsgroup. I don't remember where, but after I read about it I tried it out and it works flawlessly. And it is so much shorter to write and looks a lot nicer in then "typeof(this)". I don't think this is a accepts invalid, because according to the newsgroup this is by design, although I don't know if it is mentioned in the spec.
Comment #4 by r.sagitario — 2014-08-23T14:56:54Z
I also think this is a misfeature. Some experiments show that is very inconsistent: the following code compiles, commented lines throw an error. class Foo { this(this that, super base) { // this other = that; // static shared(super) s; } void member(this that) { } super base; // this next; shared(this) that; static shared(super) sup; } Similar stuff works for structs an "this", "super" is an undefined identifier.
Comment #5 by r.sagitario — 2014-08-23T15:03:31Z
related: issue 12228, also specifying the introducing commit.
Comment #6 by nick — 2018-05-12T13:18:17Z
> this(this other) Issue 18228 has been fixed, deprecating this syntax - closing this. Outside a parameter list, Rainer's issue is still open.