Repository navigation
Add tests for ToPropertyKey called once in **= and logical assignment - #5149
Open
chicoxyzzy wants to merge 1 commit into
Open
chicoxyzzy wants to merge 1 commit into
chicoxyzzy wants to merge 1 commit into
Conversation
GetValue stores the converted key in the Reference Record and PutValue reuses it, so base[prop] op= value converts prop once. The S11.13.2_A7.*_T4 tests check this for eleven compound operators. These tests cover **= and the &&=, ||= and ??= operators when they assign.
|
4 new or modified tests were run on 7 engines.
|
gibson042
requested changes
Nov 1, 2026
Member
There was a problem hiding this comment.
Nice catch, @chicoxyzzy! The test/language/expressions/logical-assignment/lgcl-*-assignment-operator-topropertykey-once.js files look great, but I'd like less divergence in test/language/expressions/compound-assignment (although if you're willing to pull forward the relevant old-style tests in that directory, I'm for it).
Member
There was a problem hiding this comment.
I'm generally in favor of descriptive names, but I think internal consistency wins out here. Please refactor this file for alignment with S11.13.2_A7.*_T4.js and rename it to S11.13.2_A7.12_T4.js. Then, if you like, a separate commit can rename them all and/or update their contents to this approach.
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.
base[prop] op= valueevaluatesbase[prop]to a Reference Record, then calls GetValue and PutValue on it. GetValue converts the key with ToPropertyKey and stores the result back in the record (GetValue step 3.c.i). When PutValue reaches its own conversion (PutValue step 3.c), it finds a property key and skips it, soprop'stoStringruns once. Since tc39/ecma262#3307 moved the conversion out of reference creation, that write-back is what keeps it to one call.The existing "ToPropertyKey is only called once" tests cover the update operators (
postfix-increment/S11.3.1_A6_T3.jsand its three siblings) and eleven compound operators (compound-assignment/S11.13.2_A7.1_T4.jstoS11.13.2_A7.11_T4.js). Nothing covers**=, which postdates that series, or the logical assignment operators. This adds one test for each:compound-assignment/exp-topropertykey-once.jslogical-assignment/lgcl-and-assignment-operator-topropertykey-once.jslogical-assignment/lgcl-or-assignment-operator-topropertykey-once.jslogical-assignment/lgcl-nullish-assignment-operator-topropertykey-once.jsEach logical-assignment test takes the branch that assigns. The short-circuit branch only calls GetValue, so it can't show a second conversion.
As of October 2026, engine262, JavaScriptCore, SpiderMonkey, QuickJS, Boa, XS and GraalJS pass. V8, Hermes, Kiesel, Escargot and LibJS call
toStringtwice and fail. These are the same engines that fail the existingS11.13.2_A7.*_T4andS11.3.1_A6_T3tests.