diff --git a/src/ocaml/typing/typedecl.ml b/src/ocaml/typing/typedecl.ml index 50594434f..ebbac722b 100644 --- a/src/ocaml/typing/typedecl.ml +++ b/src/ocaml/typing/typedecl.ml @@ -1955,7 +1955,9 @@ let transl_type_decl env rec_flag sdecl_list = (fun sdecl tdecl -> let decl = tdecl.typ_type in match Ctype.closed_type_decl decl with - Some ty -> raise(Error(sdecl.ptype_loc, Unbound_type_var(ty,decl))) + Some ty -> + if not (Msupport.erroneous_type_check ty) then + raise(Error(sdecl.ptype_loc, Unbound_type_var(ty,decl))) | None -> ()) sdecl_list tdecls; (* Check that constraints are enforced *) diff --git a/src/ocaml/typing/typetexp.ml b/src/ocaml/typing/typetexp.ml index 132f60f05..3bf96633b 100644 --- a/src/ocaml/typing/typetexp.ml +++ b/src/ocaml/typing/typetexp.ml @@ -644,9 +644,11 @@ let rec transl_type env ~policy ?(aliased=false) ~row_context mode styp = try transl_type_aux env ~policy ~aliased ~row_context mode styp with exn -> + let ty = new_global_var (Jkind.value ~why:(Unknown "merlin")) in + Msupport.erroneous_type_register ty; Msupport.raise_error exn; { ctyp_desc = Ttyp_var (None, None); - ctyp_type = new_global_var (Jkind.value ~why:(Unknown "merlin")); + ctyp_type = ty; ctyp_env = env; ctyp_loc = styp.ptyp_loc; ctyp_attributes = []; diff --git a/tests/test-dirs/errors/issue1704-wrong-message.t b/tests/test-dirs/errors/issue1704-wrong-message.t new file mode 100644 index 000000000..b6e7faa11 --- /dev/null +++ b/tests/test-dirs/errors/issue1704-wrong-message.t @@ -0,0 +1,59 @@ + $ cat >test.ml <<'EOF' + > type foo = { + > bar: X.t; + > } + > type foo2 = X.t + > type foo3 = bar + > EOF + +Merlin should not report unbound variable errors in that case since it is +due to it's own type recovery. + $ $MERLIN single errors -filename test.ml