Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VM: const constructor allowed to call non-const superconstructor, enables side-effects before main() #11624

Closed
rakudrama opened this issue Jun 28, 2013 · 2 comments
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

Comments

@rakudrama
Copy link
Member

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();

@iposva-google
Copy link
Contributor

Removed this from the M6 milestone.

@iposva-google
Copy link
Contributor

This is a duplicate of issue #392: Need to verify that the expressions in the initializer list are all potentially const. The I.super() call in this case isn't.


Added Duplicate label.
Marked as being merged into #392.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

2 participants