File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
crates/swc_ecma_lexer/src/common/parser Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -127,11 +127,17 @@ pub fn parse_opt_binding_ident<'a>(
127
127
) -> PResult < Option < BindingIdent > > {
128
128
trace_cur ! ( p, parse_opt_binding_ident) ;
129
129
let ctx = p. ctx ( ) ;
130
- let Some ( cur) = p. input_mut ( ) . cur ( ) else {
130
+ p. input_mut ( ) . cur ( ) ;
131
+ let Some ( token_and_span) = p. input ( ) . get_cur ( ) else {
131
132
return Ok ( None ) ;
132
133
} ;
133
- let is_binding_ident = cur. is_word ( ) && !cur. is_reserved ( ctx) ;
134
- if is_binding_ident || ( cur. is_this ( ) && p. input ( ) . syntax ( ) . typescript ( ) ) {
134
+ let cur = token_and_span. token ( ) ;
135
+ if cur. is_this ( ) && p. input ( ) . syntax ( ) . typescript ( ) {
136
+ let start = token_and_span. span ( ) . lo ;
137
+ Ok ( Some (
138
+ Ident :: new_no_ctxt ( atom ! ( "this" ) , p. span ( start) ) . into ( ) ,
139
+ ) )
140
+ } else if cur. is_word ( ) && !cur. is_reserved ( ctx) {
135
141
parse_binding_ident ( p, disallow_let) . map ( Some )
136
142
} else {
137
143
Ok ( None )
Original file line number Diff line number Diff line change @@ -395,7 +395,7 @@ pub fn parse_binding_pat_or_ident<'a, P: Parser<'a>>(
395
395
let Some ( cur) = p. input_mut ( ) . cur ( ) else {
396
396
return Err ( eof_error ( p) ) ;
397
397
} ;
398
- if cur. is_yield ( ) || cur . is_word ( ) {
398
+ if cur. is_word ( ) {
399
399
parse_binding_ident ( p, disallow_let) . map ( Pat :: from)
400
400
} else if cur. is_lbracket ( ) {
401
401
parse_array_binding_pat ( p)
You can’t perform that action at this time.
0 commit comments