Skip to content

Commit 74e004a

Browse files
committed
fix Mismatch in stability attributes error in wit-parser
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 should be able to be imported into other packages that use it. The use case for this is adding a unstable interface such as wasi-tls to wasi-cli. Once we get to resolve_include's processing we've already verified that everything checks out from a feature/version perspective for those features. i.e. we can't be trying to consolidate an interface type with a feature that hasn't already been resolved. Signed-off-by: James Sturtevant <[email protected]>
1 parent d405d00 commit 74e004a

File tree

3 files changed

+473
-10
lines changed

3 files changed

+473
-10
lines changed

Diff for: crates/wit-parser/src/resolve.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -3404,17 +3404,13 @@ impl Remap {
34043404
let prev = items.entry(key.clone()).or_insert(item.1.clone());
34053405
match (&item.1, prev) {
34063406
(
3407-
WorldItem::Interface {
3408-
id: aid,
3409-
stability: astability,
3410-
},
3411-
WorldItem::Interface {
3412-
id: bid,
3413-
stability: bstability,
3414-
},
3407+
WorldItem::Interface { id: aid, .. },
3408+
WorldItem::Interface { id: bid, .. },
34153409
) => {
3410+
// At this point in processing we care that the interfaces are the same
3411+
// but don't need to verify stability. We've already confirmed that the interface should be
3412+
// apart of the component and versions/features are enabled so if they are the same it can be used.
34163413
assert_eq!(*aid, *bid);
3417-
update_stability(astability, bstability)?;
34183414
}
34193415
(WorldItem::Interface { .. }, _) => unreachable!(),
34203416
(WorldItem::Function(_), _) => unreachable!(),
@@ -3833,7 +3829,7 @@ fn update_stability(from: &Stability, into: &mut Stability) -> Result<()> {
38333829

38343830
// Failing all that this means that the two attributes are different so
38353831
// generate an error.
3836-
bail!("mismatch in stability attributes")
3832+
bail!("mismatch in stability from '{:?}' to '{:?}'", from, into)
38373833
}
38383834

38393835
/// An error that can be returned during "world elaboration" during various
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package wasmtime:test;
2+
3+
world test{
4+
@unstable(feature = active)
5+
include wasi:unstable/imports@0.2.3;
6+
include wasi:foo/imports@0.2.3;
7+
}
8+
9+
world test-ordered{
10+
include wasi:foo/imports@0.2.3;
11+
@unstable(feature = active)
12+
include wasi:unstable/imports@0.2.3;
13+
}
14+
15+
package wasi:unstable@0.2.3 {
16+
@unstable(feature = active)
17+
world imports {
18+
@unstable(feature = active)
19+
use wasi:dep2/[email protected].{stable-resource};
20+
@unstable(feature = active)
21+
use wasi:dep-unversioned/unversioned.{unversioned-resource};
22+
@unstable(feature = active)
23+
use wasi:dep-unstable/unstable.{unstable-resource};
24+
}
25+
}
26+
27+
package wasi:foo@0.2.3 {
28+
@since(version = 0.2.0)
29+
world imports {
30+
@since(version = 0.2.0)
31+
include wasi:dep2/[email protected];
32+
include wasi:dep-unversioned/imports;
33+
include wasi:dep-unstable/imports;
34+
}
35+
}
36+
37+
package wasi:dep2@0.2.3 {
38+
@since(version = 0.2.0)
39+
world imports {
40+
@since(version = 0.2.0)
41+
import stable;
42+
}
43+
@since(version = 0.2.1)
44+
interface stable {
45+
resource stable-resource {
46+
}
47+
}
48+
}
49+
50+
package wasi:dep-unversioned{
51+
world imports {
52+
import unversioned;
53+
}
54+
interface unversioned {
55+
resource unversioned-resource {
56+
57+
}
58+
}
59+
}
60+
61+
package wasi:dep-unstable{
62+
@unstable(feature = active)
63+
world imports {
64+
@unstable(feature = active)
65+
import unstable;
66+
}
67+
@unstable(feature = active)
68+
interface unstable {
69+
@unstable(feature = active)
70+
resource unstable-resource {
71+
72+
}
73+
}
74+
}
75+

0 commit comments

Comments
 (0)