Skip to content

Typedtree module unpacks: Incorporate upstream feedback #1288

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

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
13 changes: 8 additions & 5 deletions ocaml/testsuite/tests/typing-fstclassmod/scope_escape.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ and (module A : S) =
in
();;
[%%expect{|
Line 1, characters 8-9:
1 | let rec k =
^
Error: This pattern matches values of type (module S with type t = A.t)
but a pattern was expected which matches values of type 'a
Lines 2-6, characters 2-22:
2 | ..let (module K : S with type t = A.t) = k in
3 | (module struct
4 | type t = K.t
5 | end : S
6 | with type t = K.t)
Error: This expression has type (module S with type t = A.t)
but an expression was expected of type 'a
The type constructor A.t would escape its scope
|}];;

Expand Down
16 changes: 16 additions & 0 deletions ocaml/testsuite/tests/typing-objects/Tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,14 @@ Error: This expression has type 'a t but an expression was expected of type
'a
The type variable 'a occurs inside 'a t
|}];;
fun ((x : 'a) | (x : 'a t)) -> ();;
[%%expect{|
Line 1, characters 10-12:
1 | fun ((x : 'a) | (x : 'a t)) -> ();;
^^
Error: This type 'a t should be an instance of type 'a
The type variable 'a occurs inside 'a t
|}];;
type 'a t = < x : 'a >;;
[%%expect{|
type 'a t = < x : 'a >
Expand All @@ -795,6 +803,14 @@ Line 1, characters 18-26:
Warning 10 [non-unit-statement]: this expression should have type unit.
- : ('a t as 'a) t -> unit = <fun>
|}];;
fun ((x : 'a) | (x : 'a t)) -> ();;
[%%expect{|
Line 1, characters 17-18:
1 | fun ((x : 'a) | (x : 'a t)) -> ();;
^
Warning 12 [redundant-subpat]: this sub-pattern is unused.
- : ('a t as 'a) -> unit = <fun>
|}];;

class ['a] c () = object
constraint 'a = < .. > -> unit
Expand Down
2 changes: 1 addition & 1 deletion ocaml/typing/typeclass.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ and class_expr_aux cl_num val_env met_env virt self_scope scl =
in
let partial =
let dummy = type_exp val_env (Ast_helper.Exp.unreachable ()) in
Typecore.check_partial Modules_rejected val_env pat.pat_type pat.pat_loc
Typecore.check_partial val_env pat.pat_type pat.pat_loc
[{c_lhs = pat; c_guard = None; c_rhs = dummy}]
in
let val_env' = Env.add_lock Alloc_mode.global val_env' in
Expand Down
Loading