tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

var-env-global-lex-non-strict.js (1116B)


      1 // |reftest| error:SyntaxError
      2 // Copyright (C) 2016 the V8 project authors. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 /*---
      5 esid: sec-evaldeclarationinstantiation
      6 description: Variable collision with global lexical binding
      7 info: |
      8    [...]
      9    5. If strict is false, then
     10       a. If varEnvRec is a global Environment Record, then
     11          i. For each name in varNames, do
     12             1. If varEnvRec.HasLexicalDeclaration(name) is true, throw a
     13                SyntaxError exception.
     14             2. NOTE: eval will not create a global var declaration that would
     15                be shadowed by a global lexical declaration.
     16       [...]
     17 negative:
     18  phase: runtime
     19  type: SyntaxError
     20 flags: [noStrict]
     21 features: [let]
     22 ---*/
     23 
     24 let x;
     25 
     26 // Although the `try` statement is a more precise mechanism for detecting
     27 // runtime errors, the behavior under test is only observable for a direct eval
     28 // call when the call is made from the global scope. This forces the use of
     29 // the more coarse-grained `negative` frontmatter to assert the expected error.
     30 
     31 eval('var x;');