Skip to content

Commit

Permalink
Fix regression in typeclass
Browse files Browse the repository at this point in the history
  • Loading branch information
voodoos committed Dec 20, 2024
1 parent c45c450 commit d1cacae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/ocaml/typing/typeclass.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1840,7 +1840,7 @@ let type_classes define_class approx kind env cls =
))
cls
in
let res, env =
let res, newenv =
Ctype.with_local_level_generalize_for_class begin fun () ->
let (res, env) =
List.fold_left (initial_env define_class approx) ([], env) cls
Expand All @@ -1852,10 +1852,10 @@ let type_classes define_class approx kind env cls =
res, env
end
in
let res = List.rev_map (final_decl env define_class) res in
let res = List.rev_map (final_decl newenv define_class) res in
let decls = List.fold_right extract_type_decls res [] in
let decls =
try Typedecl_variance.update_class_decls env decls
try Typedecl_variance.update_class_decls newenv decls
with Typedecl_variance.Error(loc, err) ->
raise (Typedecl.Error(loc, Typedecl.Variance err))
in
Expand Down
11 changes: 4 additions & 7 deletions tests/test-dirs/short-paths.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
"sub": [],
"valid": true,
"message": "Some type variables are unbound in this type: class b : 'a -> a
The method x has type 'c where 'c is unbound"
The method x has type 'b where 'b is unbound"
},
{
"start": {
Expand Down Expand Up @@ -309,7 +309,7 @@
"type": "typer",
"sub": [],
"valid": true,
"message": "The value x has type t but an expression was expected of type unit"
"message": "The value x has type N.O.t but an expression was expected of type unit"
},
{
"start": {
Expand All @@ -325,10 +325,7 @@
"valid": true,
"message": "Modules do not match: sig type t = int val foo : 'a -> string end
is not included in S
Values do not match:
val foo : 'a -> string
is not included in
val foo : int -> t
Values do not match: val foo : 'a -> string is not included in val foo : t -> t
The type t -> string is not compatible with the type t -> t
Type string is not compatible with type t
File \"test.ml\", line 72, characters 2-20: Expected declaration
Expand All @@ -346,7 +343,7 @@
"type": "typer",
"sub": [],
"valid": true,
"message": "The constant 5 has type int but an expression was expected of type Dep.M.t"
"message": "The constant 5 has type int but an expression was expected of type Dep.t"
}
],
"notifications": []
Expand Down

0 comments on commit d1cacae

Please sign in to comment.