Skip to content

synthetic function types are not substituted correctly #29778

Closed
@leafpetersen

Description

@leafpetersen

EDIT by @jmesserly: see comment here #29778 (comment) for description of the problem.

This bug has been recurring rather often and showed up in several other bugs, #30822 and #30207

original bug description by Leaf follows:


The following program:

void main() {
  Null Function<R>(R Function(int)) f = <S>(g) {};
}

produces the following incorrect error when run against bleeding edge analyzer:

  error • A value of type '<S₀>((int) → S) → Null' can't be assigned to a variable of type '<R>((int) → R) → Null' at /Users/leafp/tmp/test.dart:2:41 • invalid_assignment

The inferred type for the lambda is <S₀>((int) → S) → Null, instead of the presumably correct <S₀>((int) → S₀) → Null .

It looks like downwards inference is correctly choosing a new canonical type variable S₀ to use to match up R and S, but is then constructing the final inferred type using a mix of S and
S₀ to produce an invalid type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onlegacy-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