dart-lang / dart-lang/language

update spec on evaluation order of deferred checks

Open
#3,764 5 comments 0 reactions 0 assignees View on GitHub
specification technical-debt
Dominant language
TeX
Stars
2.9k
Forks
239
Avg merge
2d 18h
Merged PRs (30d)
14

Description

I couldn't find in the spec a lot of details explaining deferred checks. The program below:

```dart
import 'a.dart' deferred as a;

main() {
var x = 1;
try {
a.foo(x = 2);
} finally {
print(x);
}
```

We will be injecting a check that "a" is loaded before we allow the call to "foo". This check can be injected before or after arguments are evaluated to a value. This is implemented differently in dart2js and the VM: the example above prints 1 in dart2js and 2 in the vm.

In Dart 1 I'd have said we should implement the VM semantics. However, In Dart2 I believe we want the dart2js semantics instead: this matches the left-to-right consistency rule that we are adopting for Dart 2. I'm about to implement that in the FE at this moment.

@leafpetersen @lrhn @floitschG - can you clarify? would it be possible to explicitly call this out in the spec?

Related issue dart-lang/sdk#27577

Contributor guide

Open the contributing guide

Research direction

Start with the deferred-check evaluation example in this issue and review the existing specification text on deferred checks; the payload names no file or test. Compare the dart2js and VM outcomes described here, then resolve the intended Dart 2 ordering and document it explicitly in the spec, including whether argument assignment occurs before the load check.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
compilers, documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.