File tree Expand file tree Collapse file tree 2 files changed +6
-20
lines changed
packages/svelte/src/compiler/phases/1-parse Expand file tree Collapse file tree 2 files changed +6
-20
lines changed Original file line number Diff line number Diff line change 11/** @import { Location } from 'locate-character' */
22/** @import { Pattern } from 'estree' */
33/** @import { Parser } from '../index.js' */
4- // @ts -expect-error acorn type definitions are borked in the release we use
5- import {
6- is_bracket_open ,
7- is_bracket_close ,
8- is_bracket_pair ,
9- get_bracket_close
10- } from '../utils/bracket.js' ;
4+ import { is_bracket_open , is_bracket_close , get_bracket_close } from '../utils/bracket.js' ;
115import { parse_expression_at } from '../acorn.js' ;
126import { regex_not_newline_characters } from '../../patterns.js' ;
137import * as e from '../../../errors.js' ;
@@ -53,9 +47,12 @@ export default function read_pattern(parser) {
5347 bracket_stack . push ( char ) ;
5448 } else if ( is_bracket_close ( char ) ) {
5549 const popped = /** @type {string } */ ( bracket_stack . pop ( ) ) ;
56- if ( ! is_bracket_pair ( popped , char ) ) {
57- e . expected_token ( i , /** @type {string } */ ( get_bracket_close ( popped ) ) ) ;
50+ const expected = /** @type {string } */ ( get_bracket_close ( popped ) ) ;
51+
52+ if ( char !== expected ) {
53+ e . expected_token ( i , expected ) ;
5854 }
55+
5956 if ( bracket_stack . length === 0 ) {
6057 i += 1 ;
6158 break ;
Original file line number Diff line number Diff line change @@ -15,17 +15,6 @@ export function is_bracket_close(char) {
1515 return char === SQUARE_BRACKET_CLOSE || char === CURLY_BRACKET_CLOSE ;
1616}
1717
18- /**
19- * @param {string } open
20- * @param {string } close
21- */
22- export function is_bracket_pair ( open , close ) {
23- return (
24- ( open === SQUARE_BRACKET_OPEN && close === SQUARE_BRACKET_CLOSE ) ||
25- ( open === CURLY_BRACKET_OPEN && close === CURLY_BRACKET_CLOSE )
26- ) ;
27- }
28-
2918/** @param {string } open */
3019export function get_bracket_close ( open ) {
3120 if ( open === SQUARE_BRACKET_OPEN ) {
You can’t perform that action at this time.
0 commit comments