Skip to content

Commit

Permalink
Remove env argument to Type_error exception
Browse files Browse the repository at this point in the history
Wasn't being used, and makes refactoring typing environments awkward,
as you can't define the type error exception without first defining typing
environments
  • Loading branch information
Alasdair committed Sep 14, 2023
1 parent 8171ef5 commit 68d63b0
Show file tree
Hide file tree
Showing 12 changed files with 283 additions and 303 deletions.
4 changes: 2 additions & 2 deletions src/bin/repl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -664,9 +664,9 @@ let handle_input istate input =
| Failure str ->
print_endline ("Error: " ^ str);
istate
| Type_check.Type_error (env, _, err) ->
| Type_check.Type_error (_, err) ->
print_endline (Type_error.string_of_type_error err);
{ istate with env }
istate
| Reporting.Fatal_error err ->
Reporting.print_error ~interactive:true err;
istate
Expand Down
2 changes: 1 addition & 1 deletion src/lib/constant_fold.ml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ let rw_exp fixed target ok not_ok istate =
try
ok ();
Type_check.check_exp (env_of_annot annot) exp (typ_of_annot annot)
with Type_error (env, l, err) ->
with Type_error (l, err) ->
(* A type error here would be unexpected, so don't ignore it! *)
Reporting.warn "" l
("Type error when folding constants in "
Expand Down
4 changes: 2 additions & 2 deletions src/lib/interpreter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ let fallthrough =
check_case env exc_typ
(mk_pexp (Pat_exp (mk_pat (P_id (mk_id "exn")), mk_exp (E_throw (mk_exp (E_id (mk_id "exn")))))))
unit_typ
with Type_error (_, l, err) -> Reporting.unreachable l __POS__ (Type_error.string_of_type_error err)
with Type_error (l, err) -> Reporting.unreachable l __POS__ (Type_error.string_of_type_error err)

(**************************************************************************)
(* 1. Interpreter Monad *)
Expand Down Expand Up @@ -864,7 +864,7 @@ let rec eval_frame' = function

let eval_frame frame =
try eval_frame' frame
with Type_check.Type_error (env, l, err) -> raise (Reporting.err_typ l (Type_error.string_of_type_error err))
with Type_check.Type_error (l, err) -> raise (Reporting.err_typ l (Type_error.string_of_type_error err))

let default_effect_interp state eff =
let lstate, gstate = state in
Expand Down
2 changes: 1 addition & 1 deletion src/lib/monomorphise.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3884,7 +3884,7 @@ module BitvectorSizeCasts = struct
let arg_typ' = subst_unifiers unifiers arg_typ in
arg_typ'
end
| _ -> typ_error env l ("Malformed constructor " ^ string_of_id f ^ " with type " ^ string_of_typ ctor_typ)
| _ -> typ_error l ("Malformed constructor " ^ string_of_id f ^ " with type " ^ string_of_typ ctor_typ)
in

(* Push the cast down, including through constructors *)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/property.ml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ let add_property_guards props ast =
)
in
try Type_check.check_exp (env_of exp) exp' (typ_of exp)
with Type_error (_, l, err) ->
with Type_error (l, err) ->
let msg =
"\n\
Type error when generating guard for a property.\n\
Expand Down
8 changes: 4 additions & 4 deletions src/lib/rewrites.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2078,7 +2078,7 @@ let rewrite_vector_concat_assignments env defs =
in
begin
try check_exp env full_exp unit_typ
with Type_error (_, l, err) -> raise (Reporting.err_typ l (Type_error.string_of_type_error err))
with Type_error (l, err) -> raise (Reporting.err_typ l (Type_error.string_of_type_error err))
end
)
else E_aux (e_aux, annot)
Expand All @@ -2105,7 +2105,7 @@ let rewrite_tuple_assignments env defs =
let let_exp = mk_exp (E_let (mk_letbind pat (strip_exp exp'), block)) in
begin
try check_exp env let_exp unit_typ
with Type_error (_, l, err) -> raise (Reporting.err_typ l (Type_error.string_of_type_error err))
with Type_error (l, err) -> raise (Reporting.err_typ l (Type_error.string_of_type_error err))
end
| _ -> E_aux (e_aux, annot)
in
Expand Down Expand Up @@ -2877,7 +2877,7 @@ let rewrite_ast_pat_string_append env =
let mapping_inner_typ =
match Env.get_val_spec (mk_id mapping_prefix_func) env with
| _, Typ_aux (Typ_fn (_, Typ_aux (Typ_app (_, [A_aux (A_typ typ, _)]), _)), _) -> typ
| _ -> typ_error env Parse_ast.Unknown "mapping prefix func without correct function type?"
| _ -> typ_error Parse_ast.Unknown "mapping prefix func without correct function type?"
in

let s_id = fresh_stringappend_id () in
Expand Down Expand Up @@ -5068,7 +5068,7 @@ let rewrite effect_info env rewriters ast =
(1, (ast, effect_info, env))
rewriters
)
with Type_check.Type_error (_, l, err) -> raise (Reporting.err_typ l (Type_error.string_of_type_error err))
with Type_check.Type_error (l, err) -> raise (Reporting.err_typ l (Type_error.string_of_type_error err))

let () =
let open Interactive in
Expand Down
Loading

0 comments on commit 68d63b0

Please sign in to comment.