Skip to content

Spec doesn't specify what happens to ??= with async expressions. #24508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lrhn opened this issue Oct 6, 2015 · 3 comments
Closed

Spec doesn't specify what happens to ??= with async expressions. #24508

lrhn opened this issue Oct 6, 2015 · 3 comments
Labels
area-specification (deprecated) Deprecated: use area-language and a language- label. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@lrhn
Copy link
Member

lrhn commented Oct 6, 2015

The spec says

v ??= e is equivalent to the evaluation of the expression ((x) => x == null ? v = e : x)(v) ...

This translation is not correct if e contains an await expression.
In that case, the translation might want to not use a function expression, and be something like:
((x = v) == null ? v = e : x)
where x still fresh and declared somewhere.
This retains the synchronous execution in the non-null case that the expression suggests (if v is not null, the expression, including the await, is not executed).

@lrhn lrhn added Type-Defect area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Oct 6, 2015
@lrhn
Copy link
Member Author

lrhn commented Oct 8, 2015

(This is a general problem with many of the rewrites in the spec - if they use anonymous functions to introduce a variable, they may also change the async/sync context of the expressions moved into the synthetic function).

@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed Type-Defect labels Mar 1, 2016
@munificent munificent added area-specification (deprecated) Deprecated: use area-language and a language- label. and removed area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). docs-language-spec labels Dec 13, 2016
@eernstg
Copy link
Member

eernstg commented Feb 6, 2018

No milestone now: This does not block Dart 2.

Note that this issue is a subset of #25858.

@lrhn
Copy link
Member Author

lrhn commented Feb 7, 2018

This has been fixed. It no longer uses a function literal to "desugar" the behavior.

@lrhn lrhn closed this as completed Feb 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-specification (deprecated) Deprecated: use area-language and a language- label. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants