Wrong compiler error message regarding overload sets

Andre Pany andre at s-e-a-p.de
Tue Feb 7 20:59:00 UTC 2023


for the source code below, the compiler says:

app.d(26): constructor `app.TObject.this` hides base class 
function `app.DelphiObject.this`
app.d(26): add `alias this = app.DelphiObject.this` to 
`app.TObject`'s body to merge the overload sets

But if I add `alias this = app.DelphiObject.this` then the 
compiler says, the syntax is wrong:

Error: identifier or `new` expected following `.`, not `this`
app.d(20): Error: cannot use syntax `alias this = 
app.DelphiObject`, use `alias app.DelphiObject this` instead

But If I use `alias app.DelphiObject this` then another error is 
app.d(22): Error: no identifier for declarator `app.DelphiObject`
app.d(22):        `this` is a keyword, perhaps append `_` to make 
it an identifier

What is the correct "alias this" syntax to be able to access the 
super constructor (DelphiObjectReference)?

``` d
struct DelphiObjectReference
     ptrdiff_t reference;

mixin template PascalClass(string name)
     this (DelphiObjectReference r){}

class DelphiObject
     this (DelphiObjectReference r){}

class TObject : DelphiObject
     mixin PascalClass!("System.TObject");

     this(TObject AOwner){}

void main()
     new TObject(DelphiObjectReference(123));

Kind regards

More information about the Digitalmars-d-learn mailing list