Skip to content

Weird parser error #475

Closed
Closed
@peter-ahe-google

Description

@peter-ahe-google

This program:

final int IDENTIFIER_TOKEN = 0;

class Token {
  int kind;
}

class Fisk {
  Token peekAfterType(Token) {
    assert(token.kind === IDENTIFIER_TOKEN);
    Token peek = token.next;
  }
}

main() {
  new Fisk().peekAfterType(null);
}

Gives this error:

'foo.dart': Error: line 10 pos 11: semicolon expected
    Token peek = token.next;
          ^

Compare this to how dartc handles this problem:

foo.dart/foo.dart:10: type "Token" expected, but "PARAMETER" found
     9: assert(token.kind === IDENTIFIER_TOKEN);
    10: Token peek = token.next;
foo.dart/foo.dart:10: no such type "Token"
     9: assert(token.kind === IDENTIFIER_TOKEN);
    10: Token peek = token.next;
foo.dart/foo.dart:9: cannot resolve token
     8: Token peekAfterType(Token) {
     9: assert(token.kind === IDENTIFIER_TOKEN);
foo.dart/foo.dart:10: cannot resolve token
     9: assert(token.kind === IDENTIFIER_TOKEN);
    10: Token peek = token.next;

These are all warnings (as they should be) and the program runs and throws an dynamic error:

/var/folders/++/++3l3+++6+0++4RjPqRgNE+-QFE/-Tmp-/dart_foo.dart1176370598895860049.js:17663: TypeError: Object #<unnamedc08e84$Fisk$Dart> has no method 'token$getter'
  var peek = this.token$getter().next$getter();
                  ^
TypeError: Object #<unnamedc08e84$Fisk$Dart> has no method 'token$getter'

And here is what frogsh reports:

foo.dart:9:12: warning: can not resolve "token" on "Fisk"
    assert(token.kind === IDENTIFIER_TOKEN);
           ^^^^^
foo.dart:9:12: warning: token is not defined anywhere in the world.
    assert(token.kind === IDENTIFIER_TOKEN);
           ^^^^^
foo.dart:10:18: warning: can not resolve "token" on "Fisk"
    Token peek = token.next;
                 ^^^^^
foo.dart:10:18: warning: token is not defined anywhere in the world.
    Token peek = token.next;
                 ^^^^^

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
NoSuchMethodException - receiver: '[object Object]' function name: 'get:token' arguments: []]

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