Skip to content

Kernel inferences incorrect type for await expression. #31541

Closed
@lrhn

Description

@lrhn

Error message:

tests/language_2/await_test.dart:141:47: Error: The method '<' isn't defined for the class 'dart.async::FutureOr<dart.core::int>'.
Try correcting the name to the name of an existing method, or defining a method named '<'.
    for (var i = await(func(0)); await func(i < 5); await func(i++)) {
                                              ^
tests/language_2/await_test.dart:141:65: Error: The method '+' isn't defined for the class 'dart.async::FutureOr<dart.core::int>'.
Try correcting the name to the name of an existing method, or defining a method named '+'.
    for (var i = await(func(0)); await func(i < 5); await func(i++)) {
                                                                ^

where func has type FutureOr<T> Function<T>(T).

This means that the static type of await(func(0)) use to infer the type of i is FutureOr<int>, not int as it should be.

(See language_2/await_test when it lands).

Metadata

Metadata

Assignees

Labels

type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)web-dev-compiler

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions