Skip to content

Commit

Permalink
fix Ast_mapper not mapping over in location in let+ .. in ..
Browse files Browse the repository at this point in the history
  • Loading branch information
v-gb committed Feb 27, 2025
1 parent c154479 commit fa53910
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ profile. This started with version 0.26.0.

- Print valid syntax for the corner case (1).a (#2653, @v-gb)

- `Ast_mapper.default_mapper` now iterates on the location of `in` in `let+ .. in ..`
(#2658, @v-gb)

## 0.27.0

### Highlight
Expand Down
2 changes: 1 addition & 1 deletion test/passing/refs.default/sequence-preserve.ml.ref
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ let _ =
let foo x y =
do_some_setup x;
let* () = do_some_setup y in

(* Empty line after letop *)

important_function x;
another_important_function x y;
cleanup x y
Expand Down
2 changes: 1 addition & 1 deletion test/passing/refs.janestreet/sequence-preserve.ml.ref
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ let _ =
let foo x y =
do_some_setup x;
let* () = do_some_setup y in

(* Empty line after letop *)

important_function x;
another_important_function x y;
cleanup x y
Expand Down
2 changes: 1 addition & 1 deletion test/passing/refs.ocamlformat/sequence-preserve.ml.ref
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ let _ =
let foo x y =
do_some_setup x ;
let* () = do_some_setup y in

(* Empty line after letop *)

important_function x ;
another_important_function x y ;
cleanup x y
Expand Down
5 changes: 2 additions & 3 deletions vendor/parser-extended/ast_mapper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,7 @@ module E = struct
| Pexp_ident x -> ident ~loc ~attrs (map_loc sub x)
| Pexp_constant x -> constant ~loc ~attrs (sub.constant sub x)
| Pexp_let (lbs, e, loc_in) ->
let loc_in = sub.location sub loc_in in
let_ ~loc ~loc_in ~attrs (sub.value_bindings sub lbs)
let_ ~loc ~loc_in:(sub.location sub loc_in) ~attrs (sub.value_bindings sub lbs)
(sub.expr sub e)
| Pexp_function (ps, c, b) ->
function_ ~loc ~attrs
Expand Down Expand Up @@ -637,7 +636,7 @@ module E = struct
| Pexp_letopen (o, e) ->
letopen ~loc ~attrs (sub.open_declaration sub o) (sub.expr sub e)
| Pexp_letop {let_; ands; body; loc_in} ->
letop ~loc ~attrs ~loc_in (sub.binding_op sub let_)
letop ~loc ~attrs ~loc_in:(sub.location sub loc_in) (sub.binding_op sub let_)
(List.map (sub.binding_op sub) ands) (sub.expr sub body)
| Pexp_extension x -> extension ~loc ~attrs (sub.extension sub x)
| Pexp_unreachable -> unreachable ~loc ~attrs ()
Expand Down

0 comments on commit fa53910

Please sign in to comment.