Adjust specification of evaluation order for instance getters returning a function - #2182
Open
eernstg wants to merge 1 commit into
Open
Adjust specification of evaluation order for instance getters returning a function#2182eernstg wants to merge 1 commit into
eernstg wants to merge 1 commit into
Conversation
3 tasks
|
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 |
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 <lrn@google.com> Commit-Queue: Erik Ernst <eernst@google.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 wheregetteris 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.