[go: nahoru, domu]

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

Const constructor can redirect to non-const constructor #23622

Closed
sigurdm opened this issue Jun 11, 2015 · 6 comments
Closed

Const constructor can redirect to non-const constructor #23622

sigurdm opened this issue Jun 11, 2015 · 6 comments
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

Comments

@sigurdm
Copy link
Contributor
sigurdm commented Jun 11, 2015
class A {
  A();
  const A.redirecting() : this();
}

main() {
  print(const A.redirecting());
}

This program should fail, but prints:
Instance of 'A'

@sigurdm sigurdm added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Jun 11, 2015
@ghost ghost assigned mhausner Jun 24, 2015
@ghost ghost added the Triaged label Jun 24, 2015
@mhausner mhausner added closed-duplicate Closed in favor of an existing report area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). and removed 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 labels Jun 25, 2015
@mhausner mhausner assigned gbracha and unassigned mhausner Jun 25, 2015
@mhausner
Copy link
Contributor

I just stumped Gilad with this. There is no discussion of this in the spec. The spec should state that the redirection target must be const, just as the super initializer of a constant constructor must be a constant constructor.

@kevmoo kevmoo removed the triaged label Mar 1, 2016
@munificent munificent added area-specification (deprecated) Deprecated: use area-language and a language- label. and removed area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Dec 14, 2016
@eernstg
Copy link
Member
eernstg commented Feb 6, 2018

No milestone now: This clarification needs to be performed, but it will not block Dart 2.

@eernstg
Copy link
Member
eernstg commented Aug 24, 2018

The language specification does specify that the redirectee must be const as well, as of 715d597.

Given that the specification issue has been resolved I would close this issue. But I just checked that the given example is still accepted by the analyzer as well as the vm without errors, and dart2js crashes, so I'll relabel this issue instead.

At this time it might well turn out to be an issue for the front end only, so I won't create a meta-bug and several more specific bugs.

@eernstg eernstg added area-front-end Use area-front-end for front end / CFE / kernel format related issues. web-dart2js area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. and removed area-specification (deprecated) Deprecated: use area-language and a language- label. labels Aug 24, 2018
@a-siva
Copy link
Contributor
a-siva commented Aug 24, 2018

/cc @kmillikin

@jensjoha
Copy link
Contributor
jensjoha commented May 1, 2019

We now get this error:

t.dart:3:27: Error: A constant constructor can't call a non-constant constructor.
  const A.redirecting() : this();
                          ^

but technically still produce this class:

class A extends core::Object {
  constructor •() → self::A
    : super core::Object::•()
    ;
  const constructor redirecting() → self::A
    : this self::A::•()
    ;
}

so some error recovery might be needed (e.g. remove the const from the redirecting constructor, or make its initializer invalid-initializer or whatnot).

@srawlins
Copy link
Member

Splitting out the analyzer side of this into #27617.

@srawlins srawlins removed area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. web-dart2js labels Sep 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
Projects
None yet
Development

No branches or pull requests

9 participants