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

CFE seems to omit the scope that enables generic function types to have F-bounds #36870

Closed
iarkh opened this issue May 7, 2019 · 2 comments
Closed
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@iarkh
Copy link
Contributor

iarkh commented May 7, 2019

Dart SDK Version: 2.3.0-dev.0.5
OS: Windows 10 64 bit

The following source example declares a typedef AAlias with Function in the right part:

class A<X extends A<X>> {}
typedef AAlias = Function<X extends A<X>> ();
main() { print("OK"); }

Dart throws a compile time error here whereas analyzer passes without any errors or warnings. Sample output is:

$> dartanalyzer test.dart
$> dart test.dart
test.dart:2:39: Error: Type 'X' not found.
typedef AAlias = Function<X extends A> ();
$>

Seems like analyzer should throw an error here too.

@dgrove dgrove added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label May 8, 2019
@srawlins srawlins added the analyzer-spec Issues with the analyzer's implementation of the language spec label Jun 16, 2020
@eernstg eernstg added area-front-end Use area-front-end for front end / CFE / kernel format related issues. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed 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. labels Jun 21, 2020
@eernstg
Copy link
Member

eernstg commented Jun 21, 2020

This is actually an issue with the front end (and the error is still reported with dart from 7621137):

It is not an error to use X in the bound A<X>, because any generic function type (including one that occurs on the right hand side of a typedef) should have a scope where its type parameters are introduced, such that the type parameters can be used in F-bounds.

Changed the labels and issue title to reflect this.

@eernstg eernstg changed the title Analyzer does not throw a compile error when type in the right part of typedef is not well-bounded CFE seems to omit the scope that enables generic function types to have F-bounds Jun 21, 2020
@eernstg
Copy link
Member

eernstg commented Jun 30, 2020

Just checked, the issue arises independently of the type alias:

class A<X extends A<X>> {}
Function<X extends A<X>>() f = throw 1; // Error in CFE: Type `X` not found.
main() {}

So, apparently, function types never introduce the scope where X can be found when checking a bound like A<X>, or it does get created but it isn't made the current scope of the bounds.

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. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants