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

Analyzer does not throw a compile error for the type which is not well bounded. #47276

Open
iarkh opened this issue Sep 23, 2021 · 4 comments
Open
Labels
analyzer-spec Issues with the analyzer's implementation of the language spec area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@iarkh
Copy link
Contributor

iarkh commented Sep 23, 2021

Dart SDK version: 2.15.0-116.0.dev (dev) (Thu Sep 16 09:47:01 2021 -0700) on "windows_x64"

Analyzer does not throw a compile error for the types which are not well-bounded.

For example, dart throws a compile error whereas analyzer passes without any error or warning with the following source code example:

class A<X> {}
typedef G<X extends A<X>, Y extends A<Y>> = X Function(Y);

main() {
  print(G == int);
}

Seems like this is a bug in analyzer because G is not a well-bounded type so a error should be thrown here.

See also Issue #44786 evaluation: runtime behavior is correct, so I suppose #44786 should be closed a fixed.

Dart sample output is:

test.dart:5:9: Error: Inferred type argument 'A<dynamic>' doesn't conform to the bound 'A<X>' of the type variable 'X' on 'G'.
 - 'A' is from 'test.dart'.
Try specifying type arguments explicitly so that they conform to the bounds.
  print(G == int);
        ^
test.dart:2:11: Context: This is the type variable whose bound isn't conformed to.
typedef G<X extends A<X>, Y extends A<Y>> = X Function(Y);
          ^
test.dart:5:9: Context: If you want 'G<A<dynamic>, A<Never>>' to be a super-bounded type, note that the inverted type 'G<A<Never>, A<Object?>>' must then satisfy its bounds, which it does not.
 - 'A' is from 'test.dart'.
 - 'Object' is from 'dart:core'.
  print(G == int);
        ^
@iarkh iarkh added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Sep 23, 2021
@eernstg
Copy link
Member

eernstg commented Sep 25, 2021

so I suppose #44786 should be closed a fixed.

I commented on #44786. I think it is alive, and it is now an analyzer issue.

@eernstg
Copy link
Member

eernstg commented Sep 28, 2021

#44786 should be closed

Sorry, I did not notice that #44786 is now a duplicate of this one (the only thing in #44786 still on the table was exactly the same thing as the issue which is reported here). So I just closed #44786 as a duplicate of this one.

@srawlins srawlins added analyzer-spec Issues with the analyzer's implementation of the language spec P3 A lower priority bug or feature request labels Sep 28, 2021
@srawlins srawlins added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Nov 29, 2021
@srawlins
Copy link
Member

srawlins commented May 1, 2023

Analyzer still does not report an error.

@eernstg
Copy link
Member

eernstg commented May 1, 2023

Right, the raw G means G<A<dynamic>, A<Never>> by instantiation to bound, and that type is not well-bounded (it doesn't satisfy the declared bounds, and it is also not super bounded), so we should get a compile-time error at G.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-spec Issues with the analyzer's implementation of the language spec area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants