@@ -848,8 +848,10 @@ let reset_float_heap_sites () : unit = float_heap_sites := []
848848 the instantiated function type at that call. After checking, the first
849849 parameter of that type is the argument's type, so
850850 {!elaborate_string_concat} can pick a monomorphic lowering:
851- `slice` on a String becomes `string_slice`; `show` on Int becomes
852- `int_to_string`, on Bool an if over two literals. Same physical-identity
851+ `slice` on a String becomes `__builtin:string_slice`; `show` on Int
852+ becomes `__builtin:int_to_string` (names no program can write, so its own
853+ `string_slice` / `int_to_string` cannot capture them, #836); on Bool an if
854+ over two literals. Same physical-identity
853855 discipline as {!string_concat_sites}. *)
854856let poly_builtin_sites : (expr * ty) list ref = ref []
855857
@@ -1787,8 +1789,10 @@ let elab_poly_builtin (id : ident) (fty : ty) (args : expr list) : expr =
17871789 let arg_ty = match repr fty with TArrow (a , _ , _ , _ ) -> Some (repr a) | _ -> None in
17881790 let call name = ExprApp (ExprVar { id with name }, args) in
17891791 match id.name, arg_ty, args with
1790- | "slice" , Some (TCon "String" ), _ -> call " string_slice"
1791- | "show" , Some (TCon "Int" ), _ -> call " int_to_string"
1792+ (* #836 : `__builtin:` names cannot be written in source, so a program's
1793+ own `string_slice` / `int_to_string` never captures these calls. * )
1794+ | "slice" , Some (TCon "String" ), _ -> call " __builtin:string_slice"
1795+ | "show" , Some (TCon "Int" ), _ -> call " __builtin:int_to_string"
17921796 | "show" , Some (TCon "Bool" ), [b] ->
17931797 ExprIf { ei_cond = b;
17941798 ei_then = ExprLit (LitString (" true" , id.span));
0 commit comments