ponyc
ponyc copied to clipboard
TYPEPARAMREF modifier in constraint isn't applied properly during subtyping
In the following snippet, the compiler is able to prove X^ ≤ A iso^ in the reveal function.
However given the constraint, X can only be A tag. It seems to me like the ! modifer in the constraint is being ignored during subtyping, and so it thinks X is just an A iso.
This unsound and can be used to convert a tag back into an iso^.
class A
actor Main
new create(env: Env) =>
let opaque : A tag = A
let not_opaque : A iso = reveal[A tag, A iso](opaque)
fun reveal[X: Y!, Y: A iso](x: X) : A iso^ =>
consume x
Assigning this to myself, I'll look into it this weekend.
My guess right now is typeparam_constraint is being used in places where constraint_cap should be used.
I don't actually see a usecase for typeparam_constraint, it seems like you'd always want to use constraint_cap instead.
I don't actually see a usecase for typeparam_constraint, it seems like you'd always want to use constraint_cap instead.
swapping out for constraint_cap everywhere doesn't work. so something more surgical will be needed.