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.