v8/test/mjsunit/strong/destructuring.js
conradw 77394fa05a [parser] disallow language mode directive in body of function with non-simple parameters
TC39 agreed to disallow "use strict" directives in function body when
non-simple parameter lists are used.

This is a continuation of caitp's CL https://codereview.chromium.org/1281163002/
with some refactorings removed for now.

Still TODO: there is a lot of duplication between the is_simple field of
FormalParametersBase and the NonSimpleParameter property ExpressionClassifier
keeps track of. It should be possible to remove the former with a minor
refactoring of arrow function parsing. This will be attempted in a follow-up CL.

BUG=
LOG=N

Review URL: https://codereview.chromium.org/1300103005

Cr-Commit-Position: refs/heads/master@{#30388}
2015-08-26 14:59:19 +00:00

32 lines
959 B
JavaScript

// Copyright 2015 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.
//
// Flags: --harmony-destructuring
// Flags: --harmony-arrow-functions --strong-mode --allow-natives-syntax
(function() {
var f = (function() {
"use strong";
return function f({ x = function() { return []; } }) { return x(); };
})();
var a = f({ x: undefined });
assertTrue(%IsStrong(a));
// TODO(rossberg): Loading non-existent properties during destructuring should
// not throw in strong mode.
assertThrows(function() { f({}); }, TypeError);
function weakf({ x = function() { return []; } }) { return x(); }
a = weakf({});
assertFalse(%IsStrong(a));
function outerf() { return []; }
var f2 = (function() {
"use strong";
return function f2({ x = outerf }) { return x(); };
})();
a = f2({ x: undefined });
assertFalse(%IsStrong(a));
})();