From e9ead93f3faf0e4b5b96d634b002c7071bd3ddc9 Mon Sep 17 00:00:00 2001 From: adelaett <90894311+adelaett@users.noreply.github.com> Date: Fri, 31 Mar 2023 16:01:05 +0200 Subject: [PATCH] fix typing errors --- compiler/dcalc/interpreter.ml | 3 ++- compiler/lcalc/compile_without_exceptions.ml | 3 +-- compiler/shared_ast/expr.ml | 3 +-- compiler/shared_ast/expr.mli | 4 +--- compiler/shared_ast/program.mli | 5 +---- compiler/shared_ast/scope.ml | 7 ++++--- compiler/shared_ast/scope.mli | 4 ++-- compiler/shared_ast/typing.ml | 9 --------- 8 files changed, 12 insertions(+), 26 deletions(-) diff --git a/compiler/dcalc/interpreter.ml b/compiler/dcalc/interpreter.ml index 11de6426..ed2667a9 100644 --- a/compiler/dcalc/interpreter.ml +++ b/compiler/dcalc/interpreter.ml @@ -325,7 +325,8 @@ and evaluate_operator : | Lte_mon_mon | Lte_dat_dat | Lte_dur_dur | Gt_int_int | Gt_rat_rat | Gt_mon_mon | Gt_dat_dat | Gt_dur_dur | Gte_int_int | Gte_rat_rat | Gte_mon_mon | Gte_dat_dat | Gte_dur_dur | Eq_int_int | Eq_rat_rat - | Eq_mon_mon | Eq_dat_dat | Eq_dur_dur ), + | Eq_mon_mon | Eq_dat_dat | Eq_dur_dur | HandleDefault + | HandleDefaultOpt ), _ ) -> err () diff --git a/compiler/lcalc/compile_without_exceptions.ml b/compiler/lcalc/compile_without_exceptions.ml index 38c83654..290d713e 100644 --- a/compiler/lcalc/compile_without_exceptions.ml +++ b/compiler/lcalc/compile_without_exceptions.ml @@ -193,8 +193,7 @@ let trans_var ctx (x : 'm D.expr Var.t) : 'm Ast.expr Var.t = new_; *) new_ -let trans_op : type m. (dcalc, m) Op.t -> (lcalc, m) Op.t = - fun op -> Operator.translate None op +let trans_op : dcalc Op.t -> lcalc Op.t = fun op -> Operator.translate op let rec trans ctx (e : 'm D.expr) : (lcalc, 'm mark) boxed_gexpr = let m = Marked.get_mark e in diff --git a/compiler/shared_ast/expr.ml b/compiler/shared_ast/expr.ml index 82a086bf..59ac48a5 100644 --- a/compiler/shared_ast/expr.ml +++ b/compiler/shared_ast/expr.ml @@ -147,8 +147,7 @@ let mark_pos (type m) (m : m mark) : Pos.t = let pos (type m) (x : ('a, m mark) Marked.t) : Pos.t = mark_pos (Marked.get_mark x) -let eid mark : - ([< `Dcalc | `Desugared | `Lcalc | `Scopelang ], 'a mark) boxed_gexpr = +let eid mark : ('a any, 'm mark) boxed_gexpr = let x = Var.make "x" in eabs (bind [| x |] (evar x mark)) [TAny, mark_pos mark] mark diff --git a/compiler/shared_ast/expr.mli b/compiler/shared_ast/expr.mli index 0e454e5e..a4e18038 100644 --- a/compiler/shared_ast/expr.mli +++ b/compiler/shared_ast/expr.mli @@ -139,9 +139,7 @@ val escopecall : 't -> (([< all > `ExplicitScopes ] as 'a), 't) boxed_gexpr -val eid : - 'a mark -> - ([< `Dcalc | `Desugared | `Lcalc | `Scopelang ], 'a mark) boxed_gexpr +val eid : 'm mark -> ('a any, 'm mark) boxed_gexpr (** Manipulation of marks *) diff --git a/compiler/shared_ast/program.mli b/compiler/shared_ast/program.mli index ba543b80..c22ab2a1 100644 --- a/compiler/shared_ast/program.mli +++ b/compiler/shared_ast/program.mli @@ -41,7 +41,4 @@ val equal : bool val format : - ?debug:bool -> - Format.formatter -> - ([< `Dcalc | `Desugared | `Lcalc | `Scopelang ], 'a mark) gexpr program -> - unit + ?debug:bool -> Format.formatter -> ('a any, 'm mark) gexpr program -> unit diff --git a/compiler/shared_ast/scope.ml b/compiler/shared_ast/scope.ml index 6d9f6a51..86775a37 100644 --- a/compiler/shared_ast/scope.ml +++ b/compiler/shared_ast/scope.ml @@ -197,9 +197,10 @@ let rec format_scope_body_expr ?(debug = false) ctx fmt b : unit = Format.fprintf fmt "@[%a %a %a %a %a %a@; %a @;%a @]@,%a" Print.keyword "let" (format_scope_let_kind ~debug ctx) - scope_let_kind (if debug then Print.var_debug else Print.var) var Print.punctuation ":" (Print.typ ctx) - scope_let_typ Print.punctuation "=" (Print.expr ~debug ctx) scope_let_expr - Print.keyword "in" + scope_let_kind + (if debug then Print.var_debug else Print.var) + var Print.punctuation ":" (Print.typ ctx) scope_let_typ Print.punctuation + "=" (Print.expr ~debug ctx) scope_let_expr Print.keyword "in" (format_scope_body_expr ~debug ctx) next diff --git a/compiler/shared_ast/scope.mli b/compiler/shared_ast/scope.mli index d79854b2..b5d18dcd 100644 --- a/compiler/shared_ast/scope.mli +++ b/compiler/shared_ast/scope.mli @@ -128,7 +128,7 @@ val code_item_format : actual term. *) -> decl_ctx -> Format.formatter -> - ([< `Dcalc | `Desugared | `Lcalc | `Scopelang ], 'a mark) gexpr code_item -> + ('a any, 'm mark) gexpr code_item -> unit val code_item_list_format : @@ -138,7 +138,7 @@ val code_item_list_format : actual term. *) -> decl_ctx -> Format.formatter -> - ([< `Dcalc | `Desugared | `Lcalc | `Scopelang ], 'a mark) gexpr code_item_list -> + ('a any, 'm mark) gexpr code_item_list -> unit val to_expr : diff --git a/compiler/shared_ast/typing.ml b/compiler/shared_ast/typing.ml index 71336465..0830dd63 100644 --- a/compiler/shared_ast/typing.ml +++ b/compiler/shared_ast/typing.ml @@ -67,15 +67,6 @@ let rec typ_to_ast ~leave_unresolved (ty : unionfind_typ) : A.typ = Errors.raise_spanned_error pos "Internal error: typing at this point could not be resolved" -(* Checks that there are no type variables remaining *) -let rec all_resolved ty = - match Marked.unmark (UnionFind.get (UnionFind.find ty)) with - | TAny _ -> false - | TLit _ | TStruct _ | TEnum _ -> true - | TOption t1 | TArray t1 -> all_resolved t1 - | TArrow (t1, t2) -> List.for_all all_resolved t1 && all_resolved t2 - | TTuple ts -> List.for_all all_resolved ts - let rec ast_to_typ (ty : A.typ) : unionfind_typ = let ty' = match Marked.unmark ty with