dart-lang / dart-lang/language

Support Synchronous evaluation of FutureOr

Open
#726 4 comments 3 reactions 0 assignees View on GitHub
feature
Dominant language
TeX
Stars
2.9k
Forks
239
Avg merge
2d 18h
Merged PRs (30d)
14

Description

## Feature request

When we have a variable `FutureOr futureOr`, `await futureOr` should run synchronously when the variable is not a `Future` (see https://stackoverflow.com/q/59213196/6509751).

## Current situation

At the moment, you need to use the following code if you want to run the evaluation synchronously when possible:

```dart
if (futureOr is int)
print(futureOr + 9);
else
print((await futureOr) + 9);
```

Contributor guide

Open the contributing guide

Research direction

Start by reading the requested FutureOr behavior and the linked Stack Overflow example. Compare the proposed synchronous evaluation with the current Dart language semantics and determine which specification or implementation areas would need design work. Done means reaching agreement on the behavior and documenting or implementing the language change.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.