From 1bc685a1f7be38bf7f8f201c5a43568e8fa10b82 Mon Sep 17 00:00:00 2001 From: Pierre Villemot Date: Tue, 11 Jun 2024 13:24:30 +0200 Subject: [PATCH] Restore the check for polymorphism in enum type --- src/lib/frontend/typechecker.ml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/frontend/typechecker.ml b/src/lib/frontend/typechecker.ml index aeecef050..0f8500d46 100644 --- a/src/lib/frontend/typechecker.ml +++ b/src/lib/frontend/typechecker.ml @@ -145,6 +145,12 @@ module Types = struct | Abstract -> let ty = Ty.text ty_vars (Uid.of_string id) in ty, { env with to_ty = MString.add id ty env.to_ty } + | Enum l -> + if not (Lists.is_empty ty_vars) then + Errors.typing_error (PolymorphicEnum id) loc; + let body = List.map (fun constr -> Uid.of_string constr, []) l in + let ty = Ty.t_adt ~enum:true ~body:(Some body) (Uid.of_string id) [] in + ty, { env with to_ty = MString.add id ty env.to_ty } | Record (record_constr, lbs) -> let lbs = List.map (fun (x, pp) -> x, ty_of_pp loc env None pp) lbs in @@ -164,10 +170,6 @@ module Types = struct from_labels = List.fold_left (fun fl (l,_) -> MString.add l id fl) env.from_labels lbs } - | Enum l -> - let body = List.map (fun constr -> Uid.of_string constr, []) l in - let ty = Ty.t_adt ~enum:true ~body:(Some body) (Uid.of_string id) [] in - ty, { env with to_ty = MString.add id ty env.to_ty } | Algebraic l -> let l = (* convert ppure_type to Ty.t in l *) List.map (fun (constr, l) ->