build_subtype: assert arrow type is known (#9348)

`build_subtype` is invoked only through `enlarge_type` when typechecking Pexp_coerce.

The type passed to `build_subtype` can only have `Cok` arrows because:
- the base type is the direct result of `Typetexp.transl_simple_type_delayed` which only introduces `Cok` arrows
- the other source of arrows could be the result of unification; however at this point the type variables are fresh, they have not been unified with any existing types.

Adding this assertion ensures that this property won't be broken by accident.
master
Thomas Refis 2020-03-05 16:18:59 +01:00 committed by GitHub
parent 0c39193cc2
commit bea2d04582
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -4005,7 +4005,8 @@ let rec build_subtype env visited loops posi level t =
(t, Unchanged)
else
(t, Unchanged)
| Tarrow(l, t1, t2, _) ->
| Tarrow(l, t1, t2, com) ->
assert (com = Cok);
if memq_warn t visited then (t, Unchanged) else
let visited = t :: visited in
let (t1', c1) = build_subtype env visited loops (not posi) level t1 in