VM: const constructor allowed to call non-const superconstructor, enables side-effects before main() #11624
Labels
area-vm
Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
closed-duplicate
Closed in favor of an existing report
class I {
I() { print('xxx'); }
const I._();
}
class U extends I {
const U();
}
const x = const U();
main() {
print('Hello');
print(x);
print(const U());
}
$ sdk/bin/dart ~/play1/bug6K.dart
xxx
xxx
Hello
Instance of 'U'
Instance of 'U'
$
Removing the private const I._() gives the expected error 'superclass 'I' must be const'.
I would expect to need to change U's constructor to the following:
const U() : super._();
The superconstructor call is implicit but there is no error for an explicit non-const superconstuctor, i.e.
const U() : super();
The text was updated successfully, but these errors were encountered: