Skip to content

[analyzer] Missing error for generic function instantiation on function object #46590

Closed
@eernstg

Description

@eernstg

Consider the following program:

X id<X>(X x) => x;

void main() {
  int Function(int) f = id; // No problems, instantiates `id` as `id<int>`.
  var idVar = id; // Tears off `id`, yielding a generic function object.
  int Function(int) g = idVar; // Error.
}

The initialization of g is a compile-time error, because idVar is a variable and not a function declaration. However, the analyzer (as of commit ffde158) does not report any errors for this program.

With --enable-experiment=constructor-tearoff we should get an error at the explicit instantiation idVar<int> as well, and that error is also missing. Note that this question was discussed here.

Note that this should not be a breaking change, because the CFE already reports this error.

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work ondart-model-analyzer-specIssues with the analyzer's implementation of the language speclegacy-area-analyzerUse area-devexp instead.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions