@@ -76,16 +76,16 @@ let tag_type_to_possible_values (tag_type : Ast_untagged_variants.tag_type) :
76
76
| Untagged UnknownType -> Any
77
77
| _ -> Any
78
78
79
- let process_fields fields env type_expr_to_possible_values =
79
+ let process_fields fields env to_runtime_representation =
80
80
fields
81
81
|> List. map (fun (label : Types.label_declaration ) ->
82
82
{
83
83
optional = false (* TODO: Replicate existing rules*) ;
84
84
key = label.ld_id.name (* TODO: @as attribute *) ;
85
- value = Known (type_expr_to_possible_values label.ld_type env);
85
+ value = Known (to_runtime_representation label.ld_type env);
86
86
})
87
87
88
- let rec type_expr_to_possible_values (type_expr : Types.type_expr ) (env : Env.t )
88
+ let rec to_runtime_representation (type_expr : Types.type_expr ) (env : Env.t )
89
89
: runtime_js_value list =
90
90
match type_expr.desc with
91
91
(* Builtins *)
@@ -97,9 +97,9 @@ let rec type_expr_to_possible_values (type_expr : Types.type_expr) (env : Env.t)
97
97
when Path. same p Predef. path_float || Path. same p Predef. path_int ->
98
98
[Number {value = Unknown }]
99
99
| Tconstr (p , [inner ], _ ) when Path. same p Predef. path_option ->
100
- [UndefinedLiteral ] @ type_expr_to_possible_values inner env
100
+ [UndefinedLiteral ] @ to_runtime_representation inner env
101
101
| Tconstr (p , [inner ], _ ) when Path. same p Predef. path_dict ->
102
- [Dict {value_type = type_expr_to_possible_values inner env}]
102
+ [Dict {value_type = to_runtime_representation inner env}]
103
103
(* Types needing lookup*)
104
104
| Tconstr (_ , _ , _ ) -> (
105
105
try
@@ -109,7 +109,7 @@ let rec type_expr_to_possible_values (type_expr : Types.type_expr) (env : Env.t)
109
109
[
110
110
Object
111
111
{
112
- properties = process_fields fields env type_expr_to_possible_values ;
112
+ properties = process_fields fields env to_runtime_representation ;
113
113
can_have_unknown_properties = false ;
114
114
};
115
115
]
@@ -152,7 +152,7 @@ let rec type_expr_to_possible_values (type_expr : Types.type_expr) (env : Env.t)
152
152
key = " _" ^ string_of_int index;
153
153
value =
154
154
Known
155
- (type_expr_to_possible_values payload env);
155
+ (to_runtime_representation payload env);
156
156
}));
157
157
can_have_unknown_properties = false ;
158
158
}
@@ -175,7 +175,7 @@ let rec type_expr_to_possible_values (type_expr : Types.type_expr) (env : Env.t)
175
175
value = Known [tag_value];
176
176
};
177
177
]
178
- @ process_fields fields env type_expr_to_possible_values ;
178
+ @ process_fields fields env to_runtime_representation ;
179
179
can_have_unknown_properties = false ;
180
180
})
181
181
with Not_found -> [Any ])
@@ -200,7 +200,7 @@ let rec type_expr_to_possible_values (type_expr : Types.type_expr) (env : Env.t)
200
200
{
201
201
key = " VAL" ;
202
202
optional = false ;
203
- value = Known (type_expr_to_possible_values inner env);
203
+ value = Known (to_runtime_representation inner env);
204
204
};
205
205
];
206
206
};
@@ -232,11 +232,11 @@ let a_can_be_represented_as_b (a : runtime_js_value list)
232
232
let log t1 t2 env =
233
233
Printf. sprintf " Can be coerced: %b\n\n t1 dump: %s\n\n t2 dump: %s\n "
234
234
(a_can_be_represented_as_b
235
- (type_expr_to_possible_values t1 env)
236
- (type_expr_to_possible_values t2 env))
237
- (type_expr_to_possible_values t1 env
235
+ (to_runtime_representation t1 env)
236
+ (to_runtime_representation t2 env))
237
+ (to_runtime_representation t1 env
238
238
|> List. map debug_print_runtime_value
239
239
|> String. concat " | " )
240
- (type_expr_to_possible_values t2 env
240
+ (to_runtime_representation t2 env
241
241
|> List. map debug_print_runtime_value
242
242
|> String. concat " | " )
0 commit comments