proposal-type-imports icon indicating copy to clipboard operation
proposal-type-imports copied to clipboard

Allocation of imported types

Open tlively opened this issue 1 year ago • 3 comments

How does e.g. struct.new work when trying to instantiate an imported struct type? I guess this would need non-abstract type bounds?

tlively avatar Oct 29 '24 17:10 tlively

Construction will always need a fully defined type, so an import with upper bound won't do, even if that bound was non-abstract — it's not sufficient to know only some of the fields in that situation.

rossberg avatar Oct 29 '24 17:10 rossberg

I guess even if the number of fields is the same, you also need to know that their types are not more refined than in the provided arguments.

tlively avatar Oct 29 '24 17:10 tlively

Right. More abstractly, access is positive/covariant, while construction is negative/contravariant. For the former, an upper bound suffices, while for the latter, you need a lower bound.

rossberg avatar Oct 29 '24 17:10 rossberg