OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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: --harmony-sloppy-function |
| 6 |
| 7 // In sloppy mode we allow function redeclarations within blocks for webcompat. |
| 8 (function() { |
| 9 assertEquals(undefined, f); // Annex B |
| 10 if (true) { |
| 11 assertEquals(2, f()); |
| 12 function f() { return 1 } |
| 13 assertEquals(2, f()); |
| 14 function f() { return 2 } |
| 15 assertEquals(2, f()); |
| 16 } |
| 17 assertEquals(2, f()); // Annex B |
| 18 })(); |
| 19 |
| 20 // Should still fail in strict mode |
| 21 assertThrows(` |
| 22 (function() { |
| 23 "use strict"; |
| 24 if (true) { |
| 25 function f() { return 1 } |
| 26 function f() { return 2 } |
| 27 } |
| 28 })(); |
| 29 `, SyntaxError); |
OLD | NEW |