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

InvalidShadowInitializer for an invalid const constructor throws away target/arguments #31555

Open
MichaelRFairhurst opened this Issue Dec 6, 2017 · 1 comment

Comments

3 participants
@MichaelRFairhurst
Contributor

MichaelRFairhurst commented Dec 6, 2017

The following code:

class Base {}                                                                    
class Derived extends Base {                                                     
  const Derived();                                                               
}                                                                                
const x = const Derived(); 

throws away element data needed for the analyzer, because Base has no const constructor to be implicitly used by Derived. Rather than capturing the arguments and member/constructor that are targeted, it just reports a string error message.

    if (member.isConst && !constructor.isConst) {                                
      return buildInvalidInitializer(                                            
          deprecated_buildCompileTimeError(                                      
              "Super constructor isn't const.", charOffset),                     
          charOffset);                                                           
    }                                                                            
    needsImplicitSuperInitializer = false;                                       
    return new ShadowSuperInitializer(constructor, arguments)                    
      ..fileOffset = charOffset                                                  
      ..isSynthetic = isSynthetic; 

In our tests, we actually are still able to resolve the constant value of Derived even though its constructor is erroneous. Maybe that's not super important anymore, though?

whesse pushed a commit that referenced this issue Dec 6, 2017

Mark test_const_implicitSuperConstructorInvocation as a Fasta failure
The failure is at #31555. Once
again, its appears to be a case of erroneous code leaving out details
required to piece data back together on our side.

Bug:
Change-Id: I7ebffc5667764c0851262d61b9ea9fe4d0c0012c
Reviewed-on: https://dart-review.googlesource.com/26480
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
@stereotype441

This comment has been minimized.

Show comment
Hide comment
@stereotype441

stereotype441 Dec 6, 2017

Member

Agreed--the constructor and arguments should definitely be preserved.

It probably makes sense to wait for the representation of invalid expressions to land before working on this. @kmillikin is there an issue tracking the work you're doing on the representation of invalid expressions?

Member

stereotype441 commented Dec 6, 2017

Agreed--the constructor and arguments should definitely be preserved.

It probably makes sense to wait for the representation of invalid expressions to land before working on this. @kmillikin is there an issue tracking the work you're doing on the representation of invalid expressions?

@kmillikin kmillikin added this to Incoming in Dart Front End Jan 3, 2018

@jensjoha jensjoha moved this from Incoming Untriaged to Triaged in Dart Front End Jan 8, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment