You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[MERGE #5181@akroshg] Incorrect object shorthand error in lambda
Merge pull request #5181 from akroshg:shorthand
The object definition at lambda param should be treated as object pattern. However we had deduced that we are on right side of an expression. Which is clearly not the case.
Fixed that, by let the statement boundary determines that there is any shorthand error deferred and then throw error.
Copy file name to clipboardExpand all lines: test/es6/destructuring_bugs.js
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,9 @@ var tests = [
30
30
assert.doesNotThrow(function(){eval("for([] = ((...a) => {}) in '' ) { }");},"Having a lambda function with rest parameter as initializer should not assert and is a valid syntax");
31
31
assert.doesNotThrow(function(){eval("[[[] = [function () { }] ] = []]");},"Nested array has array pattern which has function expression is a valid syntax");
32
32
assert.doesNotThrow(function(){eval("var a = ({x = 1}) => x;");},"Lambda has Object destructuring as parameter which has initializer on shorthand is a valid syntax");
33
+
assert.doesNotThrow(function(){eval("var a = (b, {x = 1}) => x;");},"Lambda has Object destructuring as a second parameter which has initializer on shorthand is a valid syntax");
34
+
assert.doesNotThrow(function(){eval("var a = ({x = 1}, b) => x;");},"Lambda has Object destructuring as first parameter which has initializer on shorthand is a valid syntax");
35
+
assert.throws(function(){eval("let a = ({name = 'foo'}, 1) = {}");},ReferenceError,"Object shorthand will behave as pattern when on left-hand side and should not throw syntax error");
0 commit comments