Skip to content

Commit

Permalink
Restore the check for polymorphism in enum type
Browse files Browse the repository at this point in the history
  • Loading branch information
Halbaroth committed Jun 12, 2024
1 parent 226fda1 commit 1bc685a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/lib/frontend/typechecker.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) ->
Expand Down

0 comments on commit 1bc685a

Please sign in to comment.