forked from crosswalk-project/v8-crosswalk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged: [parser] Fix crash when lazy arrow func params contain destructuring assignments. Revision: bc39a51 Merged: [parser] don't rewrite destructuring assignments in params for lazy top level arrow functions Revision: 5f782db BUG=chromium:704811,chromium:706234,chromium:706761,v8:6182 LOG=N NOTRY=true NOPRESUBMIT=true NOTREECHECKS=true Change-Id: If5c04c3b9f6ac9c6879052b6a34446f895624200 Reviewed-on: https://chromium-review.googlesource.com/474746 Reviewed-by: Michael Achenbach <[email protected]> Cr-Commit-Position: refs/branch-heads/5.8@{crosswalk-project#58} Cr-Branched-From: eda659c-refs/heads/5.8.283@{crosswalk-project#1} Cr-Branched-From: 4310cd0-refs/heads/master@{#43429}
- Loading branch information
Showing
6 changed files
with
178 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Copyright 2017 the V8 project authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// The bug was that destructuring assignments which occur inside a lazy arrow | ||
// function parameter list were not rewritten. | ||
|
||
// Repro from the bug (slightly modified so that it doesn't produce a run-time | ||
// exception). | ||
(({x = {} = {}}) => {})({}); | ||
|
||
// ... and without the parens. | ||
let a0 = ({x = {} = {}}) => {}; | ||
a0({}); | ||
|
||
// Testing that the destructuring assignments also work properly. The semantics | ||
// are: The value of the destructuring assignment is an object {myprop: 2115} | ||
// and 2115 also gets assigned to global_side_assignment. So the default value | ||
// for x is {myprop: 2115}. This is the value which x will have if the function | ||
// is called with an object which doesn't have property x. | ||
let called = false; | ||
let global_side_assignment = undefined; | ||
(({x = {myprop: global_side_assignment} = {myprop: 2115}}) => { | ||
assertTrue('myprop' in x); | ||
assertEquals(2115, x.myprop); | ||
called = true; | ||
})({}); | ||
assertTrue(called); | ||
assertEquals(2115, global_side_assignment); | ||
|
||
// If the parameter is an object which has property x, the default value is not | ||
// used. | ||
called = false; | ||
global_side_assignment = undefined; | ||
(({x = {myprop: global_side_assignment} = {myprop: 2115}}) => { | ||
assertEquals(3000, x); | ||
called = true; | ||
})({x: 3000}); | ||
assertTrue(called); | ||
// Global side assignment doesn't happen, since the default value was not used. | ||
assertEquals(undefined, global_side_assignment); | ||
|
||
// Different kinds of lazy arrow functions (it's actually a bit weird that the | ||
// above functions are lazy, since they are parenthesized). | ||
called = false; | ||
global_side_assignment = undefined; | ||
let a1 = ({x = {myprop: global_side_assignment} = {myprop: 2115}}) => { | ||
assertTrue('myprop' in x); | ||
assertEquals(2115, x.myprop); | ||
called = true; | ||
} | ||
a1({}); | ||
assertTrue(called); | ||
assertEquals(2115, global_side_assignment); | ||
|
||
called = false; | ||
global_side_assignment = undefined; | ||
let a2 = ({x = {myprop: global_side_assignment} = {myprop: 2115}}) => { | ||
assertEquals(3000, x); | ||
called = true; | ||
} | ||
a2({x: 3000}); | ||
assertTrue(called); | ||
assertEquals(undefined, global_side_assignment); | ||
|
||
// We never had a problem with non-arrow functions, but testing them too for | ||
// completeness. | ||
called = false; | ||
global_side_assignment = undefined; | ||
function f1({x = {myprop: global_side_assignment} = {myprop: 2115}}) { | ||
assertTrue('myprop' in x); | ||
assertEquals(2115, x.myprop); | ||
assertEquals(2115, global_side_assignment); | ||
called = true; | ||
} | ||
f1({}); | ||
assertTrue(called); | ||
assertEquals(2115, global_side_assignment); | ||
|
||
called = false; | ||
global_side_assignment = undefined; | ||
function f2({x = {myprop: global_side_assignment} = {myprop: 2115}}) { | ||
assertEquals(3000, x); | ||
called = true; | ||
} | ||
f2({x: 3000}); | ||
assertTrue(called); | ||
assertEquals(undefined, global_side_assignment); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2017 the V8 project authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// Lazy top-level arrow function which must be re-parsed and eagerly compiled. | ||
var f = ({ x } = { x: 1 }) => { | ||
x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; | ||
x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; | ||
x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; | ||
x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; | ||
x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; | ||
x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; | ||
x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; | ||
x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;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x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; | ||
x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; | ||
x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; | ||
x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; | ||
x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; | ||
x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; | ||
x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x;x; | ||
}; | ||
|
||
f(); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright 2017 the V8 project authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
var fn = ({foo = {} = {}}) => { return foo; } | ||
if (true) { | ||
fn({}); | ||
} |