Skip to content

Static and runtime errors for main seem under-specified #1120

@leafpetersen

Description

@leafpetersen

There seem to be no static errors specified for the signature provided for main, and the runtime semantics don't seem to make it clear that as a result the invocation needs to do a dynamic type check. In practice, the VM at least seems to do so.
This program:

void main(int x) {
  x.isEven;
}

produces the following runtime error when run:

Unhandled exception:
type 'List<String>' is not a subtype of type 'int' of 'x'
#0      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#1      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

This seems like it needs clarification in the spec, and possibly tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    nnbdNNBD related issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions