Skip to content

Commit

Permalink
Remove last uses of type_is_uncurried_fun.
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianoc committed Dec 19, 2024
1 parent adc8872 commit f0a5eb6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
10 changes: 0 additions & 10 deletions compiler/ml/ast_uncurried.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,6 @@ let core_type_extract_uncurried_fun (typ : Parsetree.core_type) =
(arity, t_arg)
| _ -> assert false

let type_is_uncurried_fun (typ : Types.type_expr) =
match typ.desc with
| Tconstr (Pident {name = "function$"}, [{desc = Tarrow _}], _) -> true
| _ -> false

let type_extract_uncurried_fun (typ : Types.type_expr) =
match typ.desc with
| Tconstr (Pident {name = "function$"}, [t_arg], _) -> t_arg
| _ -> assert false

(* Typed AST *)

let tarrow_to_arity (t_arity : Types.type_expr) =
Expand Down
2 changes: 1 addition & 1 deletion compiler/ml/translcore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda =
| Some arity ->
let prim =
let expanded = Ctype.expand_head e.exp_env e.exp_type in
let extracted = Ast_uncurried.type_extract_uncurried_fun expanded in
let extracted = Ast_uncurried.remove_function_dollar expanded in
match (Btype.repr extracted).desc with
| Tarrow (Nolabel, t, _, _, _) -> (
match (Ctype.expand_head e.exp_env t).desc with
Expand Down
10 changes: 3 additions & 7 deletions compiler/ml/typecore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,9 @@ let extract_concrete_record env ty =
| _ -> raise Not_found

let extract_concrete_variant env ty =
let ty = Ast_uncurried.remove_function_dollar ty in
match extract_concrete_typedecl env ty with
| p0, p, {type_kind = Type_variant cstrs}
when not (Ast_uncurried.type_is_uncurried_fun ty) ->
(p0, p, cstrs)
| p0, p, {type_kind = Type_variant cstrs} -> (p0, p, cstrs)
| p0, p, {type_kind = Type_open} -> (p0, p, [])
| _ -> raise Not_found

Expand Down Expand Up @@ -726,7 +725,7 @@ let show_extra_help ppf _env trace =
| _ -> ()

let rec collect_missing_arguments env type1 type2 =
match type1 with
match Ast_uncurried.remove_function_dollar type1 with
(* why do we use Ctype.matches here? Please see https://github.com/rescript-lang/rescript-compiler/pull/2554 *)
| {Types.desc = Tarrow (label, argtype, typ, _, _)}
when Ctype.matches env typ type2 ->
Expand All @@ -735,9 +734,6 @@ let rec collect_missing_arguments env type1 type2 =
match collect_missing_arguments env typ type2 with
| Some res -> Some ((label, argtype) :: res)
| None -> None)
| t when Ast_uncurried.type_is_uncurried_fun t ->
let typ = Ast_uncurried.type_extract_uncurried_fun t in
collect_missing_arguments env typ type2
| _ -> None

let print_expr_type_clash ?type_clash_context env trace ppf =
Expand Down

0 comments on commit f0a5eb6

Please sign in to comment.