Skip to content

Commit 0896987

Browse files
committed
Rename [#2] to [#Has_arity2]
1 parent 9e2b411 commit 0896987

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

jscomp/ml/ast_uncurried.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
let new_representation arity = arity = 0 || arity = 5
44

5+
let encode_arity_string arity = "Has_arity" ^ string_of_int arity
6+
let decode_arity_string arity_s = int_of_string ((String.sub [@doesNotRaise]) arity_s 9 (String.length arity_s - 9))
7+
58
let arityType ~loc arity =
69
Ast_helper.Typ.variant ~loc
7-
[ Rtag ({ txt = string_of_int arity; loc }, [], true, []) ]
10+
[ Rtag ({ txt = encode_arity_string arity; loc }, [], true, []) ]
811
Closed None
912

1013
let uncurriedType ~loc ~arity tArg =
@@ -83,7 +86,7 @@ let exprExtractUncurriedFun (expr : Parsetree.expression) =
8386
(* Typed AST *)
8487

8588
let arity_to_type arity =
86-
let arity_s = string_of_int arity in
89+
let arity_s = encode_arity_string arity in
8790
Ctype.newty
8891
(Tvariant
8992
{
@@ -97,10 +100,7 @@ let arity_to_type arity =
97100

98101
let type_to_arity (tArity : Types.type_expr) =
99102
match tArity.desc with
100-
| Tvariant { row_fields = [ (label, _) ] } -> int_of_string label
101-
| Tconstr _ -> assert false
102-
| Tvar _ -> assert false
103-
| Tsubst _ -> assert false
103+
| Tvariant { row_fields = [ (label, _) ] } -> decode_arity_string label
104104
| _ -> assert false
105105

106106
let mk_js_fn ~env ~arity t =

res_syntax/src/res_uncurried.ml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,19 @@ let getDotted ~uncurried = function
1616
| Legacy -> uncurried
1717
| Default -> not uncurried
1818

19+
let encode_arity_string arity = "Has_arity" ^ string_of_int arity
20+
let decode_arity_string arity_s =
21+
(int_of_string [@doesNotRaise])
22+
((String.sub [@doesNotRaise]) arity_s 9 (String.length arity_s - 9))
23+
1924
let arityType ~loc arity =
2025
Ast_helper.Typ.variant ~loc
21-
[Rtag ({txt = string_of_int arity; loc}, [], true, [])]
26+
[Rtag ({txt = encode_arity_string arity; loc}, [], true, [])]
2227
Closed None
2328

2429
let arityFromType (typ : Parsetree.core_type) =
2530
match typ.ptyp_desc with
26-
| Ptyp_variant ([Rtag ({txt}, _, _, _)], _, _) ->
27-
(int_of_string [@doesNotRaise]) txt
31+
| Ptyp_variant ([Rtag ({txt}, _, _, _)], _, _) -> decode_arity_string txt
2832
| _ -> assert false
2933

3034
let new_representation arity = arity = 5

0 commit comments

Comments
 (0)