Skip to content

Commit

Permalink
Fix returned type of signature check
Browse files Browse the repository at this point in the history
  • Loading branch information
tjammer committed Dec 10, 2024
1 parent 7dd3eb3 commit 7e39f4a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/typing/inference.ml
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,9 @@ let types_match ?(abstracts_map = Pmap.empty) l r =
(* Unbound vars match every type *) (r, sub, true)
| Tvar { contents = Link l }, r | l, Tvar { contents = Link r } ->
aux ~strict ~in_ps sub l r
| (Qvar _ as q), Tconstr (_, [ t ]) when in_ps ->
aux ~strict ~in_ps sub q t
| Tconstr (_, [ t ]), (Qvar _ as q) when in_ps ->
aux ~strict ~in_ps sub t q
| Tconstr (n, [ t ]), (Qvar _ as q) when in_ps ->
let t, sub, b = aux ~strict ~in_ps sub t q in
(Tconstr (n, [ t ]), sub, b)
| Tconstr (pl, psl), Tconstr (pr, psr) when Path.equal pl pr ->
let sub, mtch, revps =
try
Expand Down
25 changes: 25 additions & 0 deletions test/typing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,30 @@ fun use_generic(a : thing[unit]) {
}
|}

let test_signature_deep_qvar_sg () =
test "unit"
{|type option['a] = None | Some('a)
module nullvec {
signature {
type t['a]
val of_array : (array['a]!) -> t['a]
}

type t['a] = option[array['a]]

fun of_array(arr!): Some(arr)
}

fun find_missing_deps(_ : array[unit]): ()
fun enqueue(_! : nullvec/t[unit]): 0

fun deps! {
find_missing_deps(deps)
enqueue(nullvec/of_array(deps))
}
.ignore()
|}

let test_local_modules_find_local () =
test "unit" (local_module ^ "let test : nosig/t = { a = 10 }")

Expand Down Expand Up @@ -1737,6 +1761,7 @@ let () =
test_signature_concrete_of_generic_alias;
case "generic of generic alias"
test_signature_generic_of_generic_alias;
case "deep_qvar_sg" test_signature_deep_qvar_sg;
] );
( "local modules",
[
Expand Down

0 comments on commit 7e39f4a

Please sign in to comment.