duplicate-named-capturing-groups-syntax.js (637B)
1 // Copyright 2022 Igalia, S.L. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-regexp-pattern-flags 6 description: Runtime parsing of syntax for duplicate named capturing groups 7 features: [regexp-duplicate-named-groups] 8 ---*/ 9 10 assert.throws( 11 SyntaxError, 12 () => new RegExp("(?<x>a)(?<x>b)"), 13 "Duplicate named capturing groups in the same alternative do not parse" 14 ); 15 16 let source = "(?<x>a)|(?<x>b)"; 17 let parsed = new RegExp(source); 18 assert.sameValue(parsed.source, source, "Duplicate named capturing groups in separate alternatives parse correctly"); 19 20 reportCompare(0, 0);