Repository navigation
Conversation
- Computed data properties in object literals are now defined as own
properties instead of being assigned, so a preceding getter or setter
with the same name, an inherited setter, or __proto__ no longer
interferes.
- Array patterns that were first parsed as assignment patterns now keep
element initialisers when reinterpreted as binding patterns
(e.g. `let { b: [v1 = 1] = [] } = {}`).
- A concise arrow function body no longer inherits the formal parameters
context of the enclosing function, so `await` is allowed in
`async function f(p = async (q) => await q) {}`.
Fixes #860.
Owner
|
See #879 |
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.Suggestion
2E9A
s 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.
Fixes #860. Item 1 (unary minus) is already fixed in f493a2b; this covers the other three.
2. Computed key after a getter with the same name. Non-constant computed value properties in an object literal were emitted as
setElem1/setElem1Named, which do an ordinary[[Set]]. So a preceding getter made it throw, a preceding setter got called instead of the property being created, an inherited setter onObject.prototyperan, and{ [k]: [] }withk = "__proto__"changed the prototype. Both instructions are only used for object literals, so they now define an own data property (writable/enumerable/configurable), likedefinePropdoes for classes.3. Nested patterns with defaults. In
{ b: [v1 = 1] = [] }the inner[v1 = 1]is first parsed as an assignment pattern (because of the= []), andreinterpretArrayAssignPatternAsBindingthen passed each element toreinterpretAsDestructBindingTarget, which rejectsv1 = 1. It now usesreinterpretAsBindingElement, the same as the object pattern version does. Invalid targets like[x.y = 1]or[v += 1]are still a SyntaxError.4.
awaitin a nested async arrow inside parameters. A block body opens a new scope, but a concise body is parsed in the enclosing one and so keptinFuncParamsfrom the outer function.parseArrowFunctionBodynow clears it for the concise body.async function f(p = await 1) {}andasync function f(p = () => await 1) {}are still rejected.Testing: three new tests in compiler_test.go (all fail on master, pass now);
go test ./...passes including test262;go vetandgofmtclean.