Menu

#578 Non-default base type ctor not autocalled, yet no error

closed
dkl
compiler (247)
2012-10-10
2012-01-24
dkl
No

Normally, type constructors automatically call base type constructors (and also field constructors) before doing anything else.

However, currently this only works if the base type has a default constructor. Non-default base constructors are not called automatically (see also ast-node-proc.bas:hCallBaseCtors). However, it is possible to do the call manually by using the base(params) or base.constructor(params) syntax.

This, by itself, makes sense, the compiler can't automatically call non-default base constructors, because it doesn't have the parameters. But it should show an error message, to force the user to do the call manually.

This is similar to the situation of DIMming an object that doesn't have a default ctor, without specifying an initializer: the compiler will show an "TYPE or CLASS has no default constructor" error message.

Discussion

  • dkl

    dkl - 2012-01-24

    Code example

     
  • dkl

    dkl - 2012-05-16

    I now added an appropriate error message for this case.

     

Log in to post a comment.

Monday.com Logo