Skip to content

Should static methods and methods be allowed on nested resources? #183

@alexcrichton

Description

@alexcrichton

Currently I believe given the current validation rules this is a valid component:

(component
  (import "i" (instance $i
    (export "t" (type (sub resource)))
  ))
  (alias export $i "t" (type $t))
  (import "[method]t.foo" (func (param "self" (borrow $t))))
)

Should this be valid, though? For example otherwise in a situation like:

(component
  (import "i" (instance $i
    (export "t" (type (sub resource)))
  ))
  (import "i2" (instance $i2
    (export "t" (type (sub resource)))
  ))
  ;; ...
)

you can't import a method both for $i.t and $i2.t since they'd both be called [method]t.foo.

Additionally retroactively adding methods/static methods to a type after its definition typically isn't allowed in many languages anyway, so should there perhaps be a validation predicate that if a [method] or a [static] is supplied that the mentioned resource is a top-level-import or top-level-export of the current component/instance wrapper? (this may relate a bit to #182 in that case)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions