Skip to content

Constructors without args are sometimes called unexpectedly #533

Description

@dense13

Trying to overwrite a constructor in a subclass, it kind of works but unexpectedly calls the constructor without args

class A {
    fun @construct() {
        <<< "A with no args", "" >>>;
    }
    
    fun @construct(string name) {
        <<< "A with", name>>>;
    }
}

class B extends A {
    fun @construct(string name) {
        super.A("called from B - " + name);
        <<< "B with", name>>>;
    }
}
new A("Test1") @=> A a;

new B("Test2") @=> B b;
// This will first output "A with no args"

Chuck 1.5.5.6
OS: Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions