Skip to content

Add support for throwing superclass initializers (init()) #27000

@bradcray

Description

@bradcray

At present, Chapel only supports throwing from an initializer after the init this; statement. The reason for this is that we don't currently implement the bookkeeping during field initialization to determine which fields have / have not been initialized at the time of the exception to know which we need to clean up.

One implication of this situation is that, in a class hiearchy, a superclass cannot throw, even after its init this; because the invocation of the superclass initializer from the child initializer—super.init(); comes before the child class's init this;, whether explicit or implicit. This means that in practice, only leaf class initializers can throw (or superclass initializers that are never invoked by a descendent class).

This issue proposes that we add support for this case, as it represents a coarse grain of tracking relative to field-by-field tracking of initialization, so should be strictly easier (and probably even "easy") to implement. It would also makes throwing initializers far more useful in the class hierarchy context relative to the status quo.

Associated Future Test(s):

test/classes/initializers/errors/errHandling/deinitSuperclass2.chpl #26990

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions