Skip to content

Commit 0b6d1b4

Browse files
rickyvetterbobzhang
authored andcommitted
force binding location on the actual make binding
1 parent 5a05ff8 commit 0b6d1b4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

jscomp/syntax/reactjs_jsx_ppx.cppo.ml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,9 @@ let jsxMapper () =
657657
let fileName = filenameFromLoc pstr_loc in
658658
let emptyLoc = Location.in_file fileName in
659659
let mapBinding binding = if (hasAttrOnBinding binding) then
660+
let bindingLoc = binding.pvb_loc in
661+
let bindingPatLoc = binding.pvb_pat.ppat_loc in
662+
let binding = { binding with pvb_pat = { binding.pvb_pat with ppat_loc = emptyLoc}; pvb_loc = emptyLoc} in
660663
let fnName = getFnName binding in
661664
let internalFnName = fnName ^ "$Internal" in
662665
let fullModuleName = makeModuleName fileName !nestedModules fnName in
@@ -687,7 +690,11 @@ let jsxMapper () =
687690
spelunkForFunExpression expression
688691
in
689692
let modifiedBinding binding =
690-
let wrapExpressionWithBinding expressionFn expression = Vb.mk ~attrs:(List.filter otherAttrsPure binding.pvb_attributes) (Pat.var {loc = emptyLoc; txt = fnName}) (expressionFn expression) in
693+
let wrapExpressionWithBinding expressionFn expression =
694+
Vb.mk
695+
~loc:bindingLoc
696+
~attrs:(List.filter otherAttrsPure binding.pvb_attributes)
697+
(Pat.var ~loc:bindingPatLoc {loc = bindingPatLoc; txt = fnName}) (expressionFn expression) in
691698
let expression = binding.pvb_expr in
692699
let unerasableIgnoreExp exp = { exp with pexp_attributes = (unerasableIgnore emptyLoc) :: exp.pexp_attributes } in
693700
(* TODO: there is a long-tail of unsupported features inside of blocks - Pexp_letmodule , Pexp_letexception , Pexp_ifthenelse *)

0 commit comments

Comments
 (0)