@@ -288,15 +288,6 @@ module E = struct
288288 let loc = sub.location sub loc in
289289 let attrs = sub.attributes sub attrs in
290290 match desc with
291- | Pexp_jsx_fragment (_ , xs , _ ) ->
292- (* TODO: tweak location slightly *)
293- let list_expr = Ast_helper.Exp. make_list_expression loc xs None in
294- let mapped = sub.expr sub list_expr in
295- let jsx_attr =
296- sub.attribute sub (Location. mknoloc " JSX" , Parsetree. PStr [] )
297- in
298- {mapped with pexp_attributes = jsx_attr :: attrs }
299- (* failwith "TODO Pexp_jsx_fragment 4" *)
300291 | Pexp_ident x -> ident ~loc ~attrs (map_loc sub x)
301292 | Pexp_constant x -> constant ~loc ~attrs (map_constant x)
302293 | Pexp_let (r , vbs , e ) ->
@@ -416,6 +407,18 @@ module E = struct
416407 | Pexp_open (ovf , lid , e ) ->
417408 open_ ~loc ~attrs ovf (map_loc sub lid) (sub.expr sub e)
418409 | Pexp_extension x -> extension ~loc ~attrs (sub.extension sub x)
410+ | Pexp_jsx_fragment (o , xs , c ) ->
411+ (*
412+ The location of Pexp_jsx_fragment is from the start of < till the end of />.
413+ This is not the case in the old AST. There it is from >...</
414+ *)
415+ let loc = {loc with loc_start = o; loc_end = c} in
416+ let list_expr = Ast_helper.Exp. make_list_expression loc xs None in
417+ let mapped = sub.expr sub list_expr in
418+ let jsx_attr =
419+ sub.attribute sub (Location. mknoloc " JSX" , Parsetree. PStr [] )
420+ in
421+ {mapped with pexp_attributes = jsx_attr :: attrs }
419422end
420423
421424module P = struct
0 commit comments