Skip to content

Explain why a LateInitializationError was thrown #44361

Closed
@mit-mit

Description

@mit-mit

When the VM detects an LateInitializationError with null safety, it throws a generic error like:

00:07 +5 -2: mergeWith Test [E]
  LateInitializationError: internalHandler
  package:functional_listener/src/functional_value_notifiers.dart         FunctionalValueNotifier.internalHandler
  package:functional_listener/src/functional_value_notifiers.dart 20:38   FunctionalValueNotifier.removeListener
  package:functional_listener/src/functional_value_notifiers.dart 140:11  MergingValueNotifiers.removeListener
  package:functional_listener/functional_listener.dart 223:17             ListenableSubscription.cancel
  listenable_pipe_test.dart 160:18      

This error does not detail which of the two cases of LateInitializationError happened: did we read something that wasn't initialized, or did we write to an already initialized final late variable.

It would be nice to either add this detail in the error output, or potentially even split LateInitializationError into two errors (like LateUninitializedError and LateFinalReInitializationError).

Further it could be made a bit clearer which variable triggered the exception.

Metadata

Metadata

Assignees

Labels

NNBDIssues related to NNBD ReleaseP1A high priority bug; for example, a single project is unusable or has many test failuresarea-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions