WebAssembly / component-model

Repository for design and specification of the Component Model
Other
933 stars 79 forks source link

Clarifying where `borrow` is allowed #219

Closed alexcrichton closed 1 year ago

alexcrichton commented 1 year ago

Currently the Binary.md says:

Validation only allows borrow to be used inside the param of a functype

This definitely allows (param "self" (borrow $foo)), but does it allow other things like:

(param "x" (list (borrow $foo)))

or structural types:

(type $t (record 
    (field "f" (borrow $foo))
))

(param "x" $t)
lukewagner commented 1 year ago

Good point, that's pretty fuzzy (in particular, since types are built up incrementally so that, at the point when you create a (list (borrow $R)), you don't yet know whether it will be used in a param, result, both or neither).