Home | History | Annotate | Download | only in regress
      1 // Copyright 2015 the V8 project authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // Flags: --allow-natives-syntax --turbo-filter=test*
      6 
      7 // Tests that TurboFan emits a dynamic hole-check for the temporal dead zone at
      8 // a non-initializing assignments to a {let} variable.
      9 function test_hole_check_for_let(a) {
     10   'use strict';
     11   { switch (a) {
     12       case 0: let x;
     13       case 1: x = 9;
     14     }
     15   }
     16 }
     17 assertDoesNotThrow("test_hole_check_for_let(0)");
     18 assertThrows("test_hole_check_for_let(1)", ReferenceError);
     19 %OptimizeFunctionOnNextCall(test_hole_check_for_let)
     20 assertThrows("test_hole_check_for_let(1)", ReferenceError);
     21 
     22 // Tests that TurboFan emits a dynamic hole-check for the temporal dead zone at
     23 // a non-initializing assignments to a {const} variable.
     24 function test_hole_check_for_const(a) {
     25   'use strict';
     26   { switch (a) {
     27       case 0: const x = 3;
     28       case 1: x = 2;
     29     }
     30   }
     31 }
     32 assertThrows("test_hole_check_for_const(0)", TypeError);
     33 assertThrows("test_hole_check_for_const(1)", ReferenceError);
     34 %OptimizeFunctionOnNextCall(test_hole_check_for_const)
     35 assertThrows("test_hole_check_for_const(1)", ReferenceError);
     36