File tree Expand file tree Collapse file tree 14 files changed +56
-29
lines changed Expand file tree Collapse file tree 14 files changed +56
-29
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,8 @@ let transform ~path ~pos ~debug ~typ ~hint =
1919 let cases =
2020 collectPatterns pattern
2121 |> List. map (fun (p : Parsetree.pattern ) ->
22- Ast_helper.Exp. case p (TypeUtils.Codegen. mkFailWithExp () ))
22+ Ast_helper.Exp. case p.ppat_loc p
23+ (TypeUtils.Codegen. mkFailWithExp () ))
2324 in
2425 let result = ref None in
2526 let mkIterator ~pos ~result =
Original file line number Diff line number Diff line change @@ -1044,7 +1044,7 @@ module Codegen = struct
10441044 Some
10451045 (patterns
10461046 |> List. map (fun (pat : Parsetree.pattern ) ->
1047- Ast_helper.Exp. case pat (mkFailWithExp () )))
1047+ Ast_helper.Exp. case pat.ppat_loc pat (mkFailWithExp () )))
10481048end
10491049
10501050let getModulePathRelativeToEnv ~debug ~(env : QueryEnv.t ) ~envFromItem path =
Original file line number Diff line number Diff line change @@ -105,8 +105,13 @@ module IfThenElse = struct
105105 let mkMatch ~arg ~pat =
106106 let cases =
107107 [
108- Ast_helper.Exp. case pat e1;
109- Ast_helper.Exp. case (Ast_helper.Pat. any () ) e2;
108+ Ast_helper.Exp. case
109+ {
110+ pat.Parsetree. ppat_loc with
111+ Location. loc_end = e1.pexp_loc.loc_end;
112+ }
113+ pat e1;
114+ Ast_helper.Exp. case e2.pexp_loc (Ast_helper.Pat. any () ) e2;
110115 ]
111116 in
112117 Ast_helper.Exp. match_ ~loc: e.pexp_loc ~attrs: e.pexp_attributes arg
Original file line number Diff line number Diff line change @@ -539,9 +539,9 @@ let default_mapper =
539539 ~attrs: (this.attributes this pld_attributes));
540540 cases = (fun this l -> List. map (this.case this) l);
541541 case =
542- (fun this {pc_bar ; pc_lhs; pc_guard; pc_rhs} ->
542+ (fun this {pc_loc ; pc_lhs; pc_guard; pc_rhs} ->
543543 {
544- pc_bar ;
544+ pc_loc = this.location this pc_loc ;
545545 pc_lhs = this.pat this pc_lhs;
546546 pc_guard = map_opt (this.expr this) pc_guard;
547547 pc_rhs = this.expr this pc_rhs;
Original file line number Diff line number Diff line change @@ -167,7 +167,15 @@ let expr_mapper ~async_context ~in_function_def (self : mapper)
167167 pexp_desc =
168168 Pexp_match
169169 ( pvb_expr,
170- [{pc_bar = None ; pc_lhs = p; pc_guard = None ; pc_rhs = body}] );
170+ [
171+ {
172+ pc_loc =
173+ {p.ppat_loc with Location. loc_end = body.pexp_loc.loc_end};
174+ pc_lhs = p;
175+ pc_guard = None ;
176+ pc_rhs = body;
177+ };
178+ ] );
171179 pexp_attributes = e.pexp_attributes @ pvb_attributes;
172180 })
173181 (* let [@warning "a"] {a;b} = c in body
Original file line number Diff line number Diff line change @@ -208,8 +208,8 @@ module Exp = struct
208208 jsx_container_element_closing_tag = e;
209209 }))
210210
211- let case ? bar lhs ?guard rhs =
212- {pc_bar = bar ; pc_lhs = lhs; pc_guard = guard; pc_rhs = rhs}
211+ let case loc lhs ?guard rhs =
212+ {pc_loc = loc ; pc_lhs = lhs; pc_guard = guard; pc_rhs = rhs}
213213
214214 let make_list_expression loc seq ext_opt =
215215 let rec handle_seq = function
Original file line number Diff line number Diff line change @@ -231,8 +231,7 @@ module Exp : sig
231231 Parsetree .jsx_closing_container_tag option ->
232232 expression
233233
234- val case :
235- ?bar : Lexing .position -> pattern -> ?guard : expression -> expression -> case
234+ val case : Location .t -> pattern -> ?guard : expression -> expression -> case
236235 val await : ?loc : loc -> ?attrs : attrs -> expression -> expression
237236
238237 val make_list_expression :
Original file line number Diff line number Diff line change @@ -488,9 +488,9 @@ let default_mapper =
488488 ~attrs: (this.attributes this pld_attributes));
489489 cases = (fun this l -> List. map (this.case this) l);
490490 case =
491- (fun this {pc_bar ; pc_lhs; pc_guard; pc_rhs} ->
491+ (fun this {pc_loc ; pc_lhs; pc_guard; pc_rhs} ->
492492 {
493- pc_bar ;
493+ pc_loc = this.location this pc_loc ;
494494 pc_lhs = this.pat this pc_lhs;
495495 pc_guard = map_opt (this.expr this) pc_guard;
496496 pc_rhs = this.expr this pc_rhs;
Original file line number Diff line number Diff line change @@ -665,7 +665,9 @@ let default_mapper =
665665 case =
666666 (fun this {pc_lhs; pc_guard; pc_rhs} ->
667667 {
668- pc_bar = None ;
668+ pc_loc =
669+ this.location this
670+ {pc_lhs.ppat_loc with Location. loc_end = pc_rhs.pexp_loc.loc_end};
669671 pc_lhs = this.pat this pc_lhs;
670672 pc_guard = map_opt (this.expr this) pc_guard;
671673 pc_rhs = this.expr this pc_rhs;
Original file line number Diff line number Diff line change @@ -381,7 +381,7 @@ and jsx_closing_container_tag = {
381381
382382and case = {
383383 (* (P -> E) or (P when E0 -> E) *)
384- pc_bar : Lexing .position option ;
384+ pc_loc : Location .t ;
385385 pc_lhs : pattern ;
386386 pc_guard : expression option ;
387387 pc_rhs : expression ;
You can’t perform that action at this time.
0 commit comments