Disallow `[method]...` naming unless the resource was defined in the same context
Maintainers usually reply within 4 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- wasm
- Domain
- compilers
Research direction
Start with the two component examples in this issue and the linked wasm-tools issue #2731; then locate the wasmparser validation and tests that accept these patterns. The rule for when methods may be attached is unresolved, so done means defining that rule and updating validation and tests without breaking the existing wit-component pattern unintentionally.
Written by the indexing model from the issue text.
Description
Currently wasmparser accepts this component:
(component
(import "a" (instance $a
(export "r" (type (sub resource)))
))
(alias export $a "r" (type $r))
(import "b" (instance
(export "r" (type $x (eq $r)))
(export "[method]r.f" (func (param "self" (borrow $x))))
))
)
But arguably this is a bad idea. This isn't representable in WIT at all and there aren't any actual users of this AFAIK, so I think it would be best to disallow this. In essence only the resource definition should be able to attach methods, because otherwise you could have different instances define the same method and it'd be ambiguous of what to call.
More problematically, however, wasmparser also accepts this:
(component
(type (component
(import "a" (type $a (sub resource)))
(export "r" (type $x (eq $a)))
(export "[method]r.f" (func (param "self" (borrow $x))))
))
)
and this is how wit-component works for any component which exports a resource in an interface. This means that this pattern is widely used meaning that the rule of "must be on the definition" would break a lot of components today.
Ideally wit-component would generate a component that looks like htis:
(component
(type (component
(import "a" (type $a (sub resource)))
(export "r" (type $x (eq $a)) (type (sub resource))) ;; note the type ascription here
(export "[method]r.f" (func (param "self" (borrow $x))))
))
)
but wasmparser does not yet implement that today (https://github.com/bytecodealliance/wasm-tools/issues/2731)
I'm also a bit stuck on what "must be next to the definition" means. For example a resource could be declared, then exported, and then methods must be on the type introduced by the export. In that sense some aliases work, but some don't. Hence, the issue here!
- Dominant language
- WebAssembly
- Stars
- 1.4k
- Forks
- 134
- Avg merge
- 3d 19h
- Merged PRs (30d)
- 8
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from WebAssembly/component-model
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
WebAssembly/component-model#609 · 2 comments · 1 reaction ·
Maintainers usually reply within 4 days
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
WebAssembly/component-model#769 · 1 comment ·
Maintainers usually reply within 4 days
-
Difficulty 5/5 Over a week Newbie friendliness 12/100
WebAssembly/component-model#768 · 1 comment ·
Maintainers usually reply within 4 days
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
WebAssembly/component-model#753 · 1 comment · 1 reaction ·
Maintainers usually reply within 4 days
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
WebAssembly/component-model#752 · 13 comments · 1 reaction ·
Maintainers usually reply within 4 days
All issues in WebAssembly/component-model
Similar issues
-
DAE2 crashes on call.without.effects with a non ref.func expressionPossibly taken @stevenfontanella claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
WebAssembly/binaryen#9404 ·
Maintainers usually reply within 1 day
-
area:compiler effort:S impact:med platform:windows type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
area:Analysis enhancement
Difficulty 1/5 1-3 hours Newbie friendliness 69/100
facebookresearch/atlas-lean#5118 ·
Maintainers usually reply within 1 day
-
drools: declared enum with 128 or more literals fails at class initialization (NegativeArraySizeException)Possibly taken @drccrd claimed this today. Openarea:rules
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/incubator-kie#7306 · 3 comments ·
Maintainers usually reply within 2 days
-
bug css P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day