Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mismatch in stability attributes error in wit-parser when using Unstable attribute in wit #1995

Open
jsturtevant opened this issue Feb 4, 2025 · 3 comments

Comments

@jsturtevant
Copy link

When a new interface is marked as @unstable (feature = somefeaturegate) and it uses a stable type from another package via use package:interface/type.{name} the resulting package can't be imported into other packages that use it. The resulting error is:

wasm-tools component wit --features tls ./wit/
error: mismatch in stability attributes

example

I've demonstrated this by adding a test: jsturtevant@4495325

As well as trying to integrate it into another world: https://github.com/WebAssembly/wasi-cli/compare/main...jsturtevant:wasi-cli:wasi-tls-example?expand=1 (note that this was just a test to see if I was getting in the a set up similiar to other imports)

I was getting this original from wit-bindgen macro: https://github.com/bytecodealliance/wit-bindgen/tree/main?tab=readme-ov-file#supported-guest-languages

workaround

for now I've patched wit-parser like jsturtevant@22cfe2e but it seems like there is probably a better way to approach?

@alexcrichton
Copy link
Member

Thanks for the report! I'm traveling for a bit so may take me a bit to dig in to this but I plan on doing so in the not-too-distant future

@alexcrichton
Copy link
Member

Digging into this, can you confirm that the reduced test case you have reproduces the original error you were seeing? Locally if I revert your fix on your branch and run the test suite I see:

failures:

---- "tests/ui/multi-package-features" ----
test "tests/ui/multi-package-features" failed

Caused by:
    0: failed to resolve directory while parsing WIT for path [tests/ui/multi-package-features]
    1: type `unstable-resource` not defined in interface
            --> tests/ui/multi-package-features/deps/unstable/root.wit:12:33
             |
          12 |     use wasi:dep2/[email protected].{unstable-resource};
             |                                 ^----------------


failures:
    "tests/ui/multi-package-features"

which looks different from "mismatch in stability attributes" that you were seeing with wasi-tls.

I'm definitely seeing some funny behavior that I wouldn't expect with use and feature attributes too. The test case you have can be reduced further to:

package wasmtime:test;

interface types {
  @unstable(feature = notsure)
  use wasi:dep2/stable@0.2.3.{unstable-resource};
}

package wasi:dep2@0.2.3 {
  interface stable {
    @unstable(feature = notsure)
    resource unstable-resource;
  }
}

which yields:

$ wasm-tools component wit foo.wit
error: type `unstable-resource` not defined in interface
     --> foo.wit:5:31
      |
    5 |   use wasi:dep2/[email protected].{unstable-resource};
      |                               ^----------------

and while this looks problematic it looks different from the problems you were seeing originally too

alexcrichton added a commit to alexcrichton/wasm-tools that referenced this issue Feb 10, 2025
This commit addresses an issue where stability attributes on a `use`
didn't quite work as expected when a type to another package was
referred to. This fix was to update the "merging" process to skip types
being processed in one more location which involved threading some more
contexts around. Additionally `use` items, when elaborated, now contain
their stability instead of the default stability to ensure that's
propagated correctly as well.

cc bytecodealliance#1995 but doesn't fix it
@alexcrichton
Copy link
Member

I've fixed the issue of your reduced test case (I think) as part of #2046, and it may actually end up helping the original test case, but I'd still want to confirm before closing.

github-merge-queue bot pushed a commit that referenced this issue Feb 10, 2025
This commit addresses an issue where stability attributes on a `use`
didn't quite work as expected when a type to another package was
referred to. This fix was to update the "merging" process to skip types
being processed in one more location which involved threading some more
contexts around. Additionally `use` items, when elaborated, now contain
their stability instead of the default stability to ensure that's
propagated correctly as well.

cc #1995 but doesn't fix it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants