Skip to content

Commit 71fdfc2

Browse files
committed
give meaningful error in non-fun situation in valid_redefinition
1 parent 2c58f5b commit 71fdfc2

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/typing/typeloadCheck.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ let is_generic_parameter ctx c =
4747
with Not_found ->
4848
false
4949

50-
let valid_redefinition map1 map2 f1 t1 f2 t2 = (* child, parent *)
50+
let valid_redefinition com map1 map2 f1 t1 f2 t2 = (* child, parent *)
5151
let tctx = {
5252
type_param_pairs = [];
5353
known_type_params = f1.cf_params
@@ -87,7 +87,7 @@ let valid_redefinition map1 map2 f1 t1 f2 t2 = (* child, parent *)
8787
raise (Unify_error (Cannot_unify (t1,t2) :: msg :: l))
8888
end
8989
| _ ->
90-
die "" __LOC__
90+
display_error com (Printf.sprintf "Unexpected types when checking redefinition of %s:\n\tf1: %s\n\tf2: %s" f1.cf_name (s_type_kind t1) (s_type_kind t2)) f1.cf_pos;
9191
end
9292
| _,(Var { v_write = AccNo | AccNever }) ->
9393
(* write variance *)
@@ -191,7 +191,7 @@ let check_override_field ctx p rctx =
191191
display_error ctx.com ("Field " ^ i ^ " has different property access than in superclass") p);
192192
if (has_class_field_flag rctx.cf_old CfFinal) then display_error ctx.com ("Cannot override final method " ^ i) p;
193193
try
194-
valid_redefinition rctx.map rctx.map rctx.cf_new rctx.cf_new.cf_type rctx.cf_old rctx.t_old;
194+
valid_redefinition ctx.com rctx.map rctx.map rctx.cf_new rctx.cf_new.cf_type rctx.cf_old rctx.t_old;
195195
with
196196
Unify_error l ->
197197
display_error_ext ctx.com (make_error (Custom ("Field " ^ i ^ " overrides parent class with different or incomplete type")) ~sub:([
@@ -433,7 +433,7 @@ module Inheritance = struct
433433
display_error com ("Field " ^ f.cf_name ^ " has different property access than in " ^ s_type_path intf.cl_path ^ ": " ^ s_kind f2.cf_kind ^ " should be " ^ s_kind f.cf_kind) p
434434
else try
435435
let map1 = TClass.get_map_function intf params in
436-
valid_redefinition map1 map2 f2 t2 f (apply_params intf.cl_params params f.cf_type)
436+
valid_redefinition com map1 map2 f2 t2 f (apply_params intf.cl_params params f.cf_type)
437437
with
438438
Unify_error l ->
439439
if not ((has_class_flag c CExtern)) then begin

0 commit comments

Comments
 (0)