@@ -2337,9 +2337,9 @@ pub fn parse_primary_expr_rest<'a, P: Parser<'a>>(
23372337 return parse_class_expr ( p, start, decorators. unwrap_or_default ( ) ) ;
23382338 }
23392339
2340- let try_parse_arrow_expr = |p : & mut P , id : Ident | -> PResult < Box < Expr > > {
2340+ let try_parse_arrow_expr = |p : & mut P , id : Ident , id_is_async | -> PResult < Box < Expr > > {
23412341 if can_be_arrow && !p. input_mut ( ) . had_line_break_before_cur ( ) {
2342- if id . sym == "async" && p. is_ident_ref ( ) {
2342+ if id_is_async && p. is_ident_ref ( ) {
23432343 // see https://github.com/tc39/ecma262/issues/2034
23442344 // ```js
23452345 // for(async of
@@ -2435,7 +2435,7 @@ pub fn parse_primary_expr_rest<'a, P: Parser<'a>>(
24352435 !ctx. contains ( Context :: InGenerator ) ,
24362436 !ctx. contains ( Context :: InAsync ) ,
24372437 ) ?;
2438- try_parse_arrow_expr ( p, id)
2438+ try_parse_arrow_expr ( p, id, false )
24392439 } else if cur. is_hash ( ) {
24402440 p. bump ( ) ; // consume `#`
24412441 let id = parse_ident_name ( p) ?;
@@ -2446,14 +2446,15 @@ pub fn parse_primary_expr_rest<'a, P: Parser<'a>>(
24462446 . into ( ) )
24472447 } else if p. is_ident_ref ( ) {
24482448 let cur = p. bump ( ) ;
2449+ let id_is_async = cur. is_async ( ) ;
24492450 let Some ( word) = cur. take_word ( p. input_mut ( ) ) else {
24502451 unreachable ! ( )
24512452 } ;
24522453 if p. ctx ( ) . contains ( Context :: InClassField ) && word == atom ! ( "arguments" ) {
24532454 p. emit_err ( p. input ( ) . prev_span ( ) , SyntaxError :: ArgumentsInClassField )
24542455 } ;
24552456 let id = Ident :: new_no_ctxt ( word, p. span ( token_start) ) ;
2456- try_parse_arrow_expr ( p, id)
2457+ try_parse_arrow_expr ( p, id, id_is_async )
24572458 } else {
24582459 syntax_error ! ( p, p. input( ) . cur_span( ) , SyntaxError :: TS1109 )
24592460 }
0 commit comments