Skip to content

More compact lowering of late variable error messages by front-end #43995

Open
@rakudrama

Description

@rakudrama

The front-end lowering of late variables is too large for dart2js (see #43361) and DDC.

One of the reasons is that the lowering contains comprehensive error messages.
These could be factored so that the call to the error contains only the name, and the rest of the message is provided by the constructor.
Instead of:

throw LateInitializationErrorImpl("Field 'queryParameters' has been assigned during initialization.");
throw LateInitializationErrorImpl("Local 'result' has not been initialized.");

generate:

throw LateInitializationErrorImpl.fieldAssignedDuringInitialization('queryParameters');
throw LateInitializationErrorImpl.localNotInitialized('result');

There should also be a target configuration option to omit the names as the name can be guessed from the stack-trace.
For the best code from dart2js, the LateInitializationErrorImpl constructor without the name should be a separate named constructor (not an optional name argument, as the default occurs at the call site).

/cc @johnniwinther

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