Skip to content

Should "all types are exported properly" be validated in instance types? #186

@alexcrichton

Description

@alexcrichton

I left a comment on the PR for the initial implementation of resources with some more info, but the gist is a question of whether or not this is a valid component:

(component $C
  (import "foo" (instance $i
    (type $baz' (record))
    (export $baz "baz" (type (eq $baz')))
    (type $bar' (record (field "baz" $baz)))
    (export $bar "bar" (type (eq $bar')))
  ))
  (alias export $i "bar" (type $bar))
  (type $ME (instance
    (alias outer $C $bar (type $bar'))
    (export $bar "bar" (type (eq $bar')))
  ))
)

Specifically the $ME type exports a named record $bar which internally refers to another record $baz, but the type $ME doesn't export the $baz type. This means that in isolation $ME is not a valid instance, but in the context of this component it's valid since the $baz type is imported via the "foo" import.

My heavy-handed solution to this problem arising was to completely disable all validation of "are types properly exported/imported/named/etc" for instance type definitions. When the instance type is attached to a concrete component or a component type, however, validation runs. So for example if "foo" wasn't imported then this would be an invalid component.

I wanted to confirm though that this was reasonable behavior?

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