@@ -1825,9 +1825,28 @@ and walk_expression expr t comments =
18251825 | Pexp_await expr -> walk_expression expr t comments
18261826 | Pexp_for_of (pattern, expr1, expr2)
18271827 | Pexp_for_await_of (pattern , expr1 , expr2 ) ->
1828- walk_pattern pattern t comments;
1829- walk_expression expr1 t comments;
1830- walk_expression expr2 t comments
1828+ let leading, inside, trailing =
1829+ partition_by_loc comments pattern.ppat_loc
1830+ in
1831+ attach t.leading pattern.ppat_loc leading;
1832+ walk_pattern pattern t inside;
1833+ let after_pattern, rest =
1834+ partition_adjacent_trailing pattern.ppat_loc trailing
1835+ in
1836+ attach t.trailing pattern.ppat_loc after_pattern;
1837+ let leading, inside, trailing = partition_by_loc rest expr1.pexp_loc in
1838+ attach t.leading expr1.pexp_loc leading;
1839+ walk_expression expr1 t inside;
1840+ let after_expr, rest =
1841+ partition_adjacent_trailing expr1.pexp_loc trailing
1842+ in
1843+ attach t.trailing expr1.pexp_loc after_expr;
1844+ if is_block_expr expr2 then walk_expression expr2 t rest
1845+ else
1846+ let leading, inside, trailing = partition_by_loc rest expr2.pexp_loc in
1847+ attach t.leading expr2.pexp_loc leading;
1848+ walk_expression expr2 t inside;
1849+ attach t.trailing expr2.pexp_loc trailing
18311850 | Pexp_send _ -> ()
18321851
18331852and walk_expr_parameter (_attrs , _argLbl , expr_opt , pattern ) t comments =
0 commit comments