Description
This issue was originally filed by @aam
Problem is that following sample(attached) dart compiles without errors:
===
class BankAccount {
final int balance;
BankAccount(int this.balance);
//
// const constructor initialization should not allow
// static methods invocation:
//
// see http://www.dartlang.org/docs/spec/latest/dart-language-specification.html#h.gk4elj1gohb4
//
const BankAccount.withSurprise(): this(BankAccount.draw());
static int draw() {
var isLucky = ((new Date.now().millisecond) & 42) == 42;
return isLucky? 1E9: 1E4;
}
String toString() { return "$balance"; }
}
void main() {
const ba = const BankAccount.withSurprise();
}
===
Dart compiler should have flagged line with const constructor as erroneous since initialization list invokes static method.
This is on https://dart.googlecode.com/svn/branches/bleeding_edge/dart rev 10031. Running dart on Windows.
Attachment:
testconstconstr.dart (569 Bytes)