[ppx_trace] Improve: Remove explicit dependency on Stdlib.Fun.id

Summary:
Construct the identity function explicitly instead of relying on the
`Stdlib.Fun.id` name, which can be problematic depending on compiler
version and which modules have been `open`ed.

Reviewed By: jvillard

Differential Revision: D23636204

fbshipit-source-id: 2fb644c18
master
Josh Berdine 4 years ago committed by Facebook GitHub Bot
parent 31916a2a57
commit 3ef4ce321c

@ -87,6 +87,9 @@ let vb_stack_with, vb_stack_top =
let top () = List.hd !stack in let top () = List.hd !stack in
(with_, top) (with_, top)
(* (fun x -> x) *)
let fun_id loc = pexp_fun ~loc Nolabel None (pvar ~loc "x") (evar ~loc "x")
let mapper = let mapper =
object object
inherit Ast_traverse.map as super inherit Ast_traverse.map as super
@ -129,7 +132,7 @@ let mapper =
| Pexp_extension | Pexp_extension
( {txt= "Trace.retn"; loc= retn_loc} ( {txt= "Trace.retn"; loc= retn_loc}
, PStr [{pstr_desc= Pstr_eval (retn_fun, []); _}] ) -> , PStr [{pstr_desc= Pstr_eval (retn_fun, []); _}] ) ->
if not !debug then evar ~loc:exp.pexp_loc "Stdlib.Fun.id" if not !debug then fun_id exp.pexp_loc
else else
pexp_apply ~loc:exp.pexp_loc pexp_apply ~loc:exp.pexp_loc
(evar ~loc:retn_loc "Trace.retn") (evar ~loc:retn_loc "Trace.retn")

Loading…
Cancel
Save