Skip to content

Confusing type check error in VM in checked mode #2172

Closed

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'"

Activity

  1. sethladd commented on Mar 14, 2012

    @sethladd
    ContributorAuthor

    It is unclear what a Smi is. It's not in our docs.

  2. sethladd commented on Mar 14, 2012

    @sethladd
    ContributorAuthor

    We should avoid Smi, Mint, and BigInt, which are implementation details. Dart has num, int, and double. Frog correctly warns that "int is not of type String" in this case.

  3. sethladd commented on Mar 15, 2012

    @sethladd
    ContributorAuthor

    Agreed, static warnings aren't runtime checks. However, I am concerned whenever we let implementation details bleed up to user facing messaging. Another example is when the VM talks about "GrowableArray" which is not in the spec nor in our api.dartlang.org docs. To the best of our efforts, we should hide implementation class names from user facing errors, or document these implementation names so users can track them down and not be surprised.

    Thanks for your help with this!

  4. sethladd commented on Mar 15, 2012

    @sethladd
    ContributorAuthor

    Thanks for the fix!

  5. added a commit that references this issue on Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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