Skip to content

"Null check operator used on a null value" error message should use better terminology #47185

Open
@jamesderlin

Description

@jamesderlin

Steps to reproduce:

  1. Run the following program in the Dart VM:
    void main() {
      print(null!);
    }

Result:

Unhandled exception:
Null check operator used on a null value
#0      main (file:///path/to/source_file.dart:2:13)
...

I dislike that this error message refers to postfix ! as the "Null check operator":

  • It is referred to as the "null assertion operator" in other documentation (https://dart.dev/null-safety/understanding-null-safety#null-assertion-operator), which is inconsistent.
  • "Null check operator" implies that it's performing a null check. Calling it a "null check operator" makes it confusing explaining to users that they should perform a null check first when their variable turns out to be null.

I think that the error message instead should be: "Null assertion operator used on a null value".

I'm using: Dart SDK version: 2.14.1 (stable) (Unknown timestamp) on "linux_x64".

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions