Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport #1709 #57

Merged
merged 3 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/ocaml/typing/typedecl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 *)
Expand Down
4 changes: 3 additions & 1 deletion src/ocaml/typing/typetexp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
59 changes: 59 additions & 0 deletions tests/test-dirs/errors/issue1704-wrong-message.t
Original file line number Diff line number Diff line change
@@ -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 <test.ml
{
"class": "return",
"value": [
{
"start": {
"line": 2,
"col": 7
},
"end": {
"line": 2,
"col": 10
},
"type": "typer",
"sub": [],
"valid": true,
"message": "Unbound module X"
},
{
"start": {
"line": 4,
"col": 12
},
"end": {
"line": 4,
"col": 15
},
"type": "typer",
"sub": [],
"valid": true,
"message": "Unbound module X"
},
{
"start": {
"line": 5,
"col": 12
},
"end": {
"line": 5,
"col": 15
},
"type": "typer",
"sub": [],
"valid": true,
"message": "Unbound type constructor bar"
}
],
"notifications": []
}
Loading