Skip to content

Analyzer: Initializing formals #30948

@eernstg

Description

@eernstg

This issue is based on input from MichaelRFairhurst. The analyzer parser processes a number of different constructs involving initializing formals in a way that is too permissive, or which leads to a crash. This may become a non-issue soon because of the switch to the common front end, but this issue at least serves to document the situation until then.

With dartanalyzer (and dartanalyzer --strong) version 1.25.0-dev.16.4, the following program is accepted, even though it contains a syntax error.

class C {
  var t;
  C(this.t<T>);
}

Apparently, the spurious type argument list <T> is accepted by the parser, but henceforth ignored. The result is 'No issues'.

Here are some more cases, where each variant of the constructor causes a crash:

class C {
  var t;
  C(int this.t<X>(int y)); //# 01: ok
  C(int this.t(int this.x<X>())); //# 02: compile-time error
  C(var this.t4<X>(int y)); //# 03: compile-time error
}

Apparently, initializing formals for generic functions are not yet handled at all, and this also affects the treatment of wrong initializing formals like x in subtest 02.

Metadata

Metadata

Assignees

No one assigned

    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-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions