function-redeclaration-switch.js (1399B)
1 // Copyright (C) 2019 Adrian Heine. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 description: In non-strict mode, duplicate LexicallyDeclaredNames in a switch statement's CaseBlock are allowed if they are bound by FunctionDeclarations 5 esid: sec-switch-duplicates-allowed-static-semantics 6 es6id: B.3.3.5 7 flags: [noStrict] 8 info: | 9 B.3.3.4 Changes to Block Static Semantics: Early Errors 10 11 For web browser compatibility, that rule is modified with the addition of the **highlighted** text: 12 13 Block: {StatementList} 14 15 It is a Syntax Error if the LexicallyDeclaredNames of StatementList contains any duplicate entries, **unless the source code matching this production is not strict mode code and the duplicate entries are only bound by FunctionDeclarations**. 16 17 18 B.3.3.5 Changes to switch Statement Static Semantics: Early Errors 19 20 For web browser compatibility, that rule is modified with the addition of the **highlighted** text: 21 22 SwitchStatement: switch ( Expression ) CaseBlock 23 24 It is a Syntax Error if the LexicallyDeclaredNames of CaseBlock contains any duplicate entries, **unless the source code matching this production is not strict mode code and the duplicate entries are only bound by FunctionDeclarations**. 25 ---*/ 26 27 let x 28 switch (x) { 29 case 1: 30 function a() {} 31 case 2: 32 function a() {} 33 } 34 35 reportCompare(0, 0);