Closed1
wasmgc subtyping お遊戯会場
(module
(rec
(type $Base (sub (struct (field $Base_vtable (ref null $Base_vtable)))))
(type $Base_vtable (sub (struct (field $foo i32))))
(type $Derived (sub $Base (struct (field $Derived_vtable (ref null $Derived_vtable)))))
(type $Derived_vtable (sub $Base_vtable (struct (field $foo i32))))
)
)
これはok immutable fields は covariant
(module
(rec
(type $Base (sub (struct (field $Base_vtable (mut (ref null $Base_vtable))))))
(type $Base_vtable (sub (struct (field $foo i32))))
(type $Derived (sub $Base (struct (field $Derived_vtable (mut (ref null $Derived_vtable))))))
(type $Derived_vtable (sub $Base_vtable (struct (field $foo i32))))
)
)
これはだめ (mut ...)
な mutable field は invariant なので Derived <: Base
が成り立たない
このスクラップは2024/03/04にクローズされました