Skip to content

Commit

Permalink
Restoring typechecker
Browse files Browse the repository at this point in the history
  • Loading branch information
Halbaroth committed May 24, 2024
1 parent cf97bc7 commit 8d4eb8c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
29 changes: 16 additions & 13 deletions src/lib/frontend/typechecker.ml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@ module Types = struct
match ty with
| Ty.Text (lty', s)
| Ty.Trecord { Ty.args = lty'; name = s; _ }
| Ty.Tadt (s,lty',_) ->
| Ty.Tadt (s,lty',false) ->
if List.length lty <> List.length lty' then
Errors.typing_error (WrongNumberofArgs (Uid.show s)) loc;
lty'
| Ty.Tadt (s,lty',true) ->
if List.length lty <> 0 || List.length lty' <> 0 then
Errors.typing_error (WrongNumberofArgs (Uid.show s)) loc;
[]
| _ -> assert false

let equal_pp_vars lpp lvars =
Expand Down Expand Up @@ -162,7 +166,7 @@ module Types = struct
(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 ~body:(Some body) (Uid.of_string id) [] 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 *)
Expand Down Expand Up @@ -269,8 +273,8 @@ module Env = struct
let add_fpa_enum map =
let ty = Fpa_rounding.fpa_rounding_mode in
match ty with
| Ty.Tadt (name, params, _) ->
let Adt cases = Ty.type_body name params in
| Ty.Tadt (name, [], true) ->
let Adt cases = Ty.type_body name [] in
let cstrs = List.map (fun Ty.{ constr; _ } -> constr) cases in
List.fold_left
(fun m c ->
Expand All @@ -295,11 +299,12 @@ module Env = struct

let find_builtin_cstr ty n =
match ty with
| Ty.Tadt (name, params, _) ->
let Adt cases = Ty.type_body name params in
| Ty.Tadt (name, [], true) ->
let Adt cases = Ty.type_body name [] in
let cstrs = List.map (fun Ty.{ constr; _ } -> constr) cases in
List.find (fun c -> String.equal n @@ Uid.show c) cstrs
| _ -> assert false
| _ ->
assert false

let add_fpa_builtins env =
let (->.) args result = { args; result } in
Expand Down Expand Up @@ -999,9 +1004,8 @@ let rec type_term ?(call_from_type_form=false) env f =
let ty = Ty.shorten e.c.tt_ty in
let ty_body = match ty with
| Ty.Tadt (name, params, _) ->
begin match Ty.type_body name params with
| Ty.Adt cases -> cases
end
let Ty.Adt cases = Ty.type_body name params in
cases
| Ty.Trecord { Ty.record_constr; lbs; _ } ->
[{Ty.constr = record_constr; destrs = lbs}]
| _ -> Errors.typing_error (ShouldBeADT ty) loc
Expand Down Expand Up @@ -1408,9 +1412,8 @@ and type_form ?(in_theory=false) env f =
let ty = e.c.tt_ty in
let ty_body = match ty with
| Ty.Tadt (name, params, _) ->
begin match Ty.type_body name params with
| Ty.Adt cases -> cases
end
let Ty.Adt cases = Ty.type_body name params in
cases
| Ty.Trecord { Ty.record_constr; lbs; _ } ->
[{Ty.constr = record_constr ; destrs = lbs}]

Expand Down
2 changes: 1 addition & 1 deletion src/lib/structures/fpa_rounding.ml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ let fpa_rounding_mode_dty, d_cstrs, fpa_rounding_mode =
let body =
List.map (fun (c, _) -> Uid.of_dolmen c, []) d_cstrs
in
let ty = Ty.t_adt ~body:(Some body) (Uid.of_dolmen ty_cst) [] in
let ty = Ty.t_adt ~enum:true ~body:(Some body) (Uid.of_dolmen ty_cst) [] in
DE.Ty.apply ty_cst [], d_cstrs, ty

let rounding_mode_of_smt_hs =
Expand Down

0 comments on commit 8d4eb8c

Please sign in to comment.