Give clear names to the records in records variance switching test

This commit is contained in:
Gaith Hallak 2022-05-24 22:36:45 +04:00
parent e5c6efc8ae
commit 8067d15a41
2 changed files with 36 additions and 46 deletions

View File

@ -993,19 +993,16 @@ failing_contracts() ->
, ?TYPE_ERROR(polymorphism_variance_switching_records,
[<<?Pos(27,13)
"Cannot unify `Animal` and `Cat` in a covariant context\n"
"when checking the type of the pattern `r03 : rec_a(Cat)` against the expected type `Main.rec_a(Animal)`">>,
"when checking the type of the pattern `r03 : rec_co(Cat)` against the expected type `Main.rec_co(Animal)`">>,
<<?Pos(33,13)
"Cannot unify `Cat` and `Animal` in a contravariant context\n"
"when checking the type of the pattern `r06 : rec_b(Animal)` against the expected type `Main.rec_b(Cat)`">>,
<<?Pos(41,13)
"Cannot unify `Animal` and `Cat` in a covariant context\n"
"when checking the type of the pattern `r11 : rec_c(Cat)` against the expected type `Main.rec_c(Animal)`">>,
<<?Pos(47,13)
"when checking the type of the pattern `r06 : rec_contra(Animal)` against the expected type `Main.rec_contra(Cat)`">>,
<<?Pos(40,13)
"Cannot unify `Cat` and `Animal` in a invariant context\n"
"when checking the type of the pattern `r16 : rec_d(Animal)` against the expected type `Main.rec_d(Cat)`">>,
<<?Pos(48,13)
"when checking the type of the pattern `r10 : rec_inv(Animal)` against the expected type `Main.rec_inv(Cat)`">>,
<<?Pos(41,13)
"Cannot unify `Animal` and `Cat` in a invariant context\n"
"when checking the type of the pattern `r17 : rec_d(Cat)` against the expected type `Main.rec_d(Animal)`">>])
"when checking the type of the pattern `r11 : rec_inv(Cat)` against the expected type `Main.rec_inv(Animal)`">>])
, ?TYPE_ERROR(polymorphism_variance_switching_oracles,
[<<?Pos(15,13)
"Cannot unify `Cat` and `Animal` in a contravariant context\n"

View File

@ -5,12 +5,12 @@ contract Cat : Animal =
entrypoint sound() = "meow"
main contract Main =
record rec_a('a) = { x : 'a }
record rec_b('a) = { x : 'a => unit }
record rec_c('a) = { x : () => 'a}
record rec_d('a) = { x : 'a => unit,
y : () => 'a }
record rec_e('a) = { x : int }
record rec_co('a) = { x : 'a ,
y : () => 'a }
record rec_contra('a) = { x : 'a => unit }
record rec_inv('a) = { x : 'a => unit,
y : () => 'a }
record rec_biv('a) = { x : int }
stateful entrypoint new_cat() : Cat = Chain.create()
stateful entrypoint new_animal() : Animal = new_cat()
@ -20,39 +20,32 @@ main contract Main =
stateful entrypoint unit_to_cat() : Cat = new_cat()
stateful entrypoint init() =
let ra : rec_a(Animal) = { x = new_animal() }
let rc : rec_a(Cat) = { x = new_cat() }
let r01 : rec_a(Animal) = ra // success
let r02 : rec_a(Animal) = rc // success
let r03 : rec_a(Cat) = ra // fail
let r04 : rec_a(Cat) = rc // sucess
let ra : rec_co(Animal) = { x = new_animal(), y = unit_to_animal }
let rc : rec_co(Cat) = { x = new_cat(), y = unit_to_cat }
let r01 : rec_co(Animal) = ra // success
let r02 : rec_co(Animal) = rc // success
let r03 : rec_co(Cat) = ra // fail
let r04 : rec_co(Cat) = rc // sucess
let ratu : rec_b(Animal) = { x = animal_to_unit }
let rctu : rec_b(Cat) = { x = cat_to_unit }
let r05 : rec_b(Animal) = ratu // success
let r06 : rec_b(Animal) = rctu // fail
let r07 : rec_b(Cat) = ratu // success
let r08 : rec_b(Cat) = rctu // success
let ratu : rec_contra(Animal) = { x = animal_to_unit }
let rctu : rec_contra(Cat) = { x = cat_to_unit }
let r05 : rec_contra(Animal) = ratu // success
let r06 : rec_contra(Animal) = rctu // fail
let r07 : rec_contra(Cat) = ratu // success
let r08 : rec_contra(Cat) = rctu // success
let ruta : rec_c(Animal) = { x = unit_to_animal }
let rutc : rec_c(Cat) = { x = unit_to_cat }
let r09 : rec_c(Animal) = ruta // success
let r10 : rec_c(Animal) = rutc // success
let r11 : rec_c(Cat) = ruta // fail
let r12 : rec_c(Cat) = rutc // success
let rxaya : rec_inv(Animal) = { x = animal_to_unit, y = unit_to_animal }
let rxcyc : rec_inv(Cat) = { x = cat_to_unit, y = unit_to_cat }
let r09 : rec_inv(Animal) = rxaya // success
let r10 : rec_inv(Animal) = rxcyc // fail
let r11 : rec_inv(Cat) = rxaya // fail
let r12 : rec_inv(Cat) = rxcyc // success
let rxaya : rec_d(Animal) = { x = animal_to_unit, y = unit_to_animal }
let rxcyc : rec_d(Cat) = { x = cat_to_unit, y = unit_to_cat }
let r13 : rec_d(Animal) = rxaya // success
let r16 : rec_d(Animal) = rxcyc // fail
let r17 : rec_d(Cat) = rxaya // fail
let r20 : rec_d(Cat) = rxcyc // success
let rba : rec_e(Animal) = { x = 1 }
let rbc : rec_e(Cat) = { x = 1 }
let r21 : rec_e(Animal) = rba // success
let r21 : rec_e(Animal) = rbc // success
let r22 : rec_e(Cat) = rba // success
let r22 : rec_e(Cat) = rbc // success
let rba : rec_biv(Animal) = { x = 1 }
let rbc : rec_biv(Cat) = { x = 1 }
let r13 : rec_biv(Animal) = rba // success
let r14 : rec_biv(Animal) = rbc // success
let r15 : rec_biv(Cat) = rba // success
let r16 : rec_biv(Cat) = rbc // success
()