Skip to content

Parser should report an error when 'super' is used as an expression. #43168

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

Open
scheglov opened this issue Aug 24, 2020 · 7 comments
Open

Parser should report an error when 'super' is used as an expression. #43168

scheglov opened this issue Aug 24, 2020 · 7 comments
Labels
legacy-area-front-end Legacy: Use area-dart-model instead.

Comments

@scheglov
Copy link
Contributor

scheglov commented Aug 24, 2020

[Comment by eernstg: Note that the analyzer still does not report an error in the example shown here. I'm changing the labels accordingly.]

This code currently has no errors in analyzer, but fails with CFE.
I think this is a bug in the analyzer.
But as @bwilkerson correctly pointed out, this is a syntactic error, and reported by the parser.

class A {
  int foo() => 0;
}

class B extends A {
  void bar() {
    print(super);
    super!;
  }
}

main() {
  B().bar();
}
@scheglov scheglov added legacy-area-analyzer Use area-devexp instead. dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec labels Aug 24, 2020
@scheglov scheglov self-assigned this Aug 24, 2020
@scheglov scheglov changed the title Report CompileTimeErrorCode.SUPER_AS_EXPRESSION in more places Report ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR in more places Aug 24, 2020
@scheglov scheglov changed the title Report ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR in more places Parser should report ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR in more places Aug 25, 2020
@scheglov scheglov changed the title Parser should report ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR in more places Parser should report an error when 'super' is used an expression. Aug 25, 2020
@scheglov scheglov added legacy-area-front-end Legacy: Use area-dart-model instead. and removed dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec legacy-area-analyzer Use area-devexp instead. labels Aug 25, 2020
dart-bot pushed a commit that referenced this issue Aug 25, 2020
Partial implementation to unblock:
https://dart-review.googlesource.com/c/sdk/+/159966, to unlock:
https://dart-review.googlesource.com/c/sdk/+/159960

Bug: #43168
Change-Id: I5e3891f4ddf15c747568b38b794d75fcbd30c03a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159971
Reviewed-by: Brian Wilkerson <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
@jonasfj
Copy link
Member

jonasfj commented Aug 25, 2020

I'm not entirely sure why I was assigned (typo?) :D

@jonasfj jonasfj removed their assignment Aug 25, 2020
@lrhn lrhn changed the title Parser should report an error when 'super' is used an expression. Parser should report an error when 'super' is used as an expression. Aug 25, 2020
@bwilkerson
Copy link
Member

@jensjoha

@scheglov scheglov assigned jensjoha and unassigned scheglov Aug 25, 2020
@sgrekhov
Copy link
Contributor

sgrekhov commented Aug 17, 2022

This is still an issue

class C {
  foo() {
    print(super); // No error in analyzer, in CFE Error: Can't use 'super' as an expression.
  }
}

main() {
  C().foo();
}

Dart SDK version: 2.19.0-81.0.dev (dev) (Tue Aug 9 14:51:36 2022 -0700) on "windows_x64"

@eernstg please confirm that it is an analyzer issue

@eernstg eernstg added legacy-area-analyzer Use area-devexp instead. dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec and removed legacy-area-front-end Legacy: Use area-dart-model instead. labels Aug 23, 2022
@eernstg
Copy link
Member

eernstg commented Aug 23, 2022

I agree that this is still an issue in the analyzer, I changed the labels accordingly.

@bwilkerson
Copy link
Member

I agree that this is still an issue in the analyzer, I changed the labels accordingly.

I don't understand why this isn't an issue for the parser. My understanding is that parse(super); is not valid Dart code because it doesn't conform to the grammar. Such problems should be caught by the parser so that we can avoid exactly the kind of inconsistency between the front end and the analyzer that's been mentioned above.

@eernstg
Copy link
Member

eernstg commented Aug 23, 2022

Oh, it could very well be an issue for the parser, but I just verified that the error is missing for the analyzer, and it is reported for the CFE.

@bwilkerson bwilkerson added legacy-area-front-end Legacy: Use area-dart-model instead. and removed legacy-area-analyzer Use area-devexp instead. dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec labels Aug 23, 2022
@bwilkerson
Copy link
Member

@jensjoha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy-area-front-end Legacy: Use area-dart-model instead.
Projects
None yet
Development

No branches or pull requests

6 participants