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>(
127127) -> PResult < Option < BindingIdent > > {
128128 trace_cur ! ( p, parse_opt_binding_ident) ;
129129 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 {
131132 return Ok ( None ) ;
132133 } ;
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) {
135141 parse_binding_ident ( p, disallow_let) . map ( Some )
136142 } else {
137143 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>>(
395395 let Some ( cur) = p. input_mut ( ) . cur ( ) else {
396396 return Err ( eof_error ( p) ) ;
397397 } ;
398- if cur. is_yield ( ) || cur . is_word ( ) {
398+ if cur. is_word ( ) {
399399 parse_binding_ident ( p, disallow_let) . map ( Pat :: from)
400400 } else if cur. is_lbracket ( ) {
401401 parse_array_binding_pat ( p)
You can’t perform that action at this time.
0 commit comments