Skip to content

Confusing type check error in VM in checked mode #2172

@sethladd

Description

@sethladd

This code:

import('dart:builtin');

add(String a, String b) {
  return a + b;
}

void main() {
  print(add(1, 2));
}

When run in the VM w/ checked mode, and via the Editor, generates this error:

Unhandled exception:
type 'Smi' is not a subtype of type 'String' of 'a'.
 0. Function: '::add' url: 'file:///Users/sethladd/dart/optionaltypes/optionaltypes.dart' line:3 col:12
 1. Function: '::main' url: 'file:///Users/sethladd/dart/optionaltypes/optionaltypes.dart' line:8 col:12

It is unclear and confusing what "Smi" is. It should read: "type 'int' is not a subtype of type 'String' of 'a'"

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

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions