Skip to content
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

Adjust specification of evaluation order for instance getters returning a function #2182

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

eernstg
Copy link
Member

@eernstg eernstg commented Apr 1, 2022

Cf. dart-lang/sdk#36744.

This PR changes the language specification such that it specifies that the actual arguments are evaluated before the getter is invoked in the evaluation of an expression of the form receiver.getter(arguments), in the case where getter is an instance getter. In all other cases we keep the currently specified (and implemented) semantics, which is to evaluate left-to-right, getter first and then actual arguments.

This means that we will have an inconsistency in the language, but we avoid the breakage associated with the approach where all tools are changed to use a strict left-to-right evaluation order.

@github-actions
Copy link

github-actions bot commented Apr 1, 2022

Visit the preview URL for this PR (updated for commit b441d93):

https://dart-specification--pr2182-specify-evaluation-o-zdnixe3p.web.app

(expires Fri, 08 Apr 2022 14:29:44 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 6941ecd630c4f067ff3d02708a45ae0f0a42b88a

@eernstg eernstg changed the title Adjust specification of evaluation order for instance methods Adjust specification of evaluation order for instance getters returning a function Apr 1, 2022
copybara-service bot pushed a commit to dart-lang/sdk that referenced this pull request Apr 8, 2022
This CL adds a test of the evaluation order in the case where a function
invocation `g(a)` or `r.g(a)` involves the invocation of a getter `g` that
returns a function object, and that function object is invoked with an
actual argument `a`.

The expectation in the test is that evaluation occurs left-to-right in
every case, with one exception: when `g` is a class instance getter (this
does not apply to extension instance getters) the actual argument list
is evaluated before the getter. This is the actually implemented behavior,
and the specification is being updated to specify this behavior
(cf. dart-lang/language#2182).

------- Old description:

A piece of technical debt which has been around for several years is the
fact that the specified left-to-right evaluation order isn't implemented
everywhere.

In particular, with an ordinary invocation like `r.m(a)` where `m` is a
getter that returns a function, the argument is evaluated before the
getter is called, which is not a left-to-right ordering.

This CL adds a test (with 2 libraries) where the evaluation order is
detected, such that we can decide how to proceed.

Change-Id: Ia2619fe6b4c4cf4cec63bac9c9f834306bdefe52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238903
Reviewed-by: Lasse Nielsen <[email protected]>
Commit-Queue: Erik Ernst <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant