-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
It took me quite a while to figure this out (in a larger program):
bug2.dart:
class Foo {
Bar bar;
Foo() {
Bar = new Bar();
}
}
main() {
var x = new Foo();
}
class Bar {
}
sra@limpopo:~/play1$ ../dart-all/dart/frog/frogsh --out=t.js bug2.dart
bug2.dart:12:1: We are sorry, but... can not be property
class Bar {
^^^^^^^^^^^^
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
CompilerException: bug2.dart:12:1: We are sorry, but... can not be property
class Bar {
^^^^^^^^^^^^
at World._lang_message (/usr/local/google/home/sra/dart-all/dart/frog/frogsh:15707:5)
at World.internalError (/usr/local/google/home/sra/dart-all/dart/frog/frogsh:15726:8)
at TypeMember.providePropertySyntax (/usr/local/google/home/sra/dart-all/dart/frog/frogsh:8958:16)
at MemberSet.get$treatAsField (/usr/local/google/home/sra/dart-all/dart/frog/frogsh:9948:16)
at MethodGenerator._visitVarAssign (/usr/local/google/home/sra/dart-all/dart/frog/frogsh:8129:18)
at MethodGenerator._visitAssign (/usr/local/google/home/sra/dart-all/dart/frog/frogsh:8101:17)
at MethodGenerator.visitBinaryExpression (/usr/local/google/home/sra/dart-all/dart/frog/frogsh:8090:17)
at BinaryExpression.visit (/usr/local/google/home/sra/dart-all/dart/frog/frogsh:13837:18)
at MethodGenerator.visitValue (/usr/local/google/home/sra/dart-all/dart/frog/frogsh:7566:20)
at MethodGenerator.visitVoid (/usr/local/google/home/sra/dart-all/dart/frog/frogsh:7581:15)
The problem is that the assignment at line 4 has the class name as a LHS. 'Bar' should be 'bar'.
The diagnostic should indicate the line with the error. If 'Bar' has been underlined I think I would have got it.
Maybe line 12 could be a secondary diagnostic, e.g.
bug2.dart:4:4: class 'Bar' can not be target of assignment
Bar = new Bar();
^^^
bug2.dart:12:1: class 'Bar' defined here.
The VM does a reasonable job:
'bug2.dart': Error: line 4 pos 9: Left hand side of '=' is not assignable
Bar = new Bar();
^