Repository navigation
fix(codemode): live Map/Set forEach, generator prototypes, repeated function declarations, delete on non-references - #50450
Merged
Merged
Conversation
…unction declarations, delete on non-references
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.
Five small JS-conformance fixes, each a few lines.
const m = new Map([[1, "a"], [2, "b"]]) m.forEach((v, k) => { if (k === 1) { m.delete(2); m.set(3, "c") } log(k) }) -1 2 // walked a snapshot +1 3 // live, as in JS: deleted entries skipped, added ones visited function* g() {} -g() instanceof g // TypeError: no 'prototype' object +g() instanceof g // true; each generator function has its own prototype function f() { return 1 } function f() { return 2 } - // TypeError: Identifier 'f' has already been declared +f() // 2; last declaration wins, and `var f` may share the name const fact = function inner(n) { return n <= 1 ? 1 : n * inner(n - 1) } -fact(4) // ReferenceError: Unknown identifier 'inner' +fact(4) // 24; a named function expression sees its own name, read-only -delete 0 // TypeError: Only data fields may be deleted +delete 0 // true; the operand is evaluated. `delete variable` still throws.Where
forEach: drop theArray.fromsnapshot; the host Map/Set iterator is already livestdlib/collections.tscreateFunction: defineprototypeon generator functions; push a read-only own-name scope for named function expressionsinterpreter/interpreter.tscreateGenerator: use the function'sprototypeas the generator's protointerpreter/interpreter.tshoistFunctions:scope.setinstead ofscope.declareinterpreter/interpreter.tsevaluateDeleteExpression: non-member, non-identifier operand → evaluate,trueinterpreter/interpreter.tsFn.capturedScopesis nowArray(it was already a fresh copy fromcapture())interpreter/objects.tsPlain functions still have no
prototype— they cannot construct here. Assigning to a named function expression's own name throws (strict-mode behavior); sloppy JS ignores it silently.Tests
Eight
skipped.txtentries removed (statements/function/S13_A3_T1,S13_A6_T1,S14_A2,S14_A5_T1/T2,statements/generators/has-instance,prototype-typeof,prototype-uniqueness). Two[ ]lines ininterpreter-support.mdflipped to[x].