summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Function/StrictFunction_reservedwords_with.js
blob: 46a21ed5f1b87b9be85de1c81a0c5ae92c8c7120 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright (C) 2020 Xing Qu. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-createdynamicfunction
description: Strictfunction shouldn't have the reserved word "with"
info: |
    CreateDynamicFunction ( constructor, newTarget, kind, args )
    
    ...
    20 Perform the following substeps in an implementation-dependent order, possibly interleaving parsing and error detection:
      ...
      c. Let strict be ContainsUseStrict of body.
      d. If any static semantics errors are detected for parameters or body, throw a SyntaxError exception. 
         If strict is true, the Early Error rules for UniqueFormalParameters:FormalParameters are applied.
      ...
    ...
---*/

assert.throws(SyntaxError, function() {
  new Function("'use strict'; with ({}) {}");
}, '`new Function("\'use strict\'; with ({}) {}")` throws a SyntaxError exception');

reportCompare(0, 0);