nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: bytecodealliance/wasm-tools
Pull request #1718 (2024-08-12 21:21:05)

Fix a spuriously-printed DWARF warning
If an error was found before the code section a DWARF-related warning was printed but that's not relevant and is false information, so squash the warning.


Patch:
diff --git a/src/addr2line.rs b/src/addr2line.rs
index 1be023c5..68822c2f 100644
--- a/src/addr2line.rs
+++ b/src/addr2line.rs
@@ -103,10 +103,8 @@ impl<'a> Addr2lineModules<'a> {
         let text_relative_addr = if code_section_relative {
             addr
         } else {
-            match module.code_start {
-                Some(start) => addr
-                    .checked_sub(start)
-                    .context("address is before the beginning of the text section")?,
+            match module.code_start.and_then(|start| addr.checked_sub(start)) {
+                Some(rel) => rel,
                 None => return Ok(None),
             }
         };


Test patch:
diff --git a/tests/cli/invalid-before-code.wat b/tests/cli/invalid-before-code.wat
new file mode 100644
index 00000000..d80334d4
--- /dev/null
+++ b/tests/cli/invalid-before-code.wat
@@ -0,0 +1,6 @@
+;; FAIL: validate %
+
+(module
+  (type (func (param (ref 100))))
+  (func)
+)
diff --git a/tests/cli/invalid-before-code.wat.stderr b/tests/cli/invalid-before-code.wat.stderr
new file mode 100644
index 00000000..eacda384
--- /dev/null
+++ b/tests/cli/invalid-before-code.wat.stderr
@@ -0,0 +1,1 @@
+error: unknown type 100: type index out of bounds (at offset 0xb)
Repository: bytecodealliance/wasm-tools
Pull request #1732 (2024-08-21 17:43:02)

Enable gc, function-references, and exceptions by default
This commit enables three new proposals by default in `WasmFeatures` to reflect the stage 4+ status of the proposals.


Patch:
diff --git a/crates/wasmparser/src/features.rs b/crates/wasmparser/src/features.rs
index 3f61ffcc..fc154b16 100644
--- a/crates/wasmparser/src/features.rs
+++ b/crates/wasmparser/src/features.rs
@@ -126,7 +126,7 @@ define_wasm_features! {
         /// The WebAssembly multi memory proposal.
         pub multi_memory: MULTI_MEMORY(1 << 12) = true;
         /// The WebAssembly exception handling proposal.
-        pub exceptions: EXCEPTIONS(1 << 13) = false;
+        pub exceptions: EXCEPTIONS(1 << 13) = true;
         /// The WebAssembly memory64 proposal.
         pub memory64: MEMORY64(1 << 14) = false;
         /// The WebAssembly extended_const proposal.
@@ -134,11 +134,11 @@ define_wasm_features! {
         /// The WebAssembly component model proposal.
         pub component_model: COMPONENT_MODEL(1 << 16) = true;
         /// The WebAssembly typed function references proposal.
-        pub function_references: FUNCTION_REFERENCES(1 << 17) = false;
+        pub function_references: FUNCTION_REFERENCES(1 << 17) = true;
         /// The WebAssembly memory control proposal.
         pub memory_control: MEMORY_CONTROL(1 << 18) = false;
         /// The WebAssembly gc proposal.
-        pub gc: GC(1 << 19) = false;
+        pub gc: GC(1 << 19) = true;
         /// The WebAssembly [custom-page-sizes
         /// proposal](https://github.com/WebAssembly/custom-page-sizes).
         pub custom_page_sizes: CUSTOM_PAGE_SIZES(1 << 20) = false;


Test patch:
diff --git a/tests/roundtrip.rs b/tests/roundtrip.rs
index b10d56bf..bf8350fc 100644
--- a/tests/roundtrip.rs
+++ b/tests/roundtrip.rs
@@ -598,8 +598,9 @@ impl TestState {
         for part in test.iter().filter_map(|t| t.to_str()) {
             match part {
                 "testsuite" => {
-                    features = WasmFeatures::default();
-                    features.remove(WasmFeatures::COMPONENT_MODEL);
+                    features = WasmFeatures::wasm2();
+                    features |= WasmFeatures::TAIL_CALL;
+                    features |= WasmFeatures::EXTENDED_CONST;
 
                     // NB: when these proposals are merged upstream in the spec
                     // repo then this should be removed. Currently this hasn't
Repository: bytecodealliance/wasm-tools
Pull request #1743 (2024-08-28 15:01:59)

Don't print custom section data with `--skeleton`
Custom sections can be quite large with dwarf debugging information so print only `...` in `--skeleton` mode.


Patch:
diff --git a/crates/wasmprinter/src/lib.rs b/crates/wasmprinter/src/lib.rs
index 8a7b2a56..4c54dc8c 100644
--- a/crates/wasmprinter/src/lib.rs
+++ b/crates/wasmprinter/src/lib.rs
@@ -2756,7 +2756,11 @@ impl Printer<'_, '_> {
             write!(self.result, " ({place})")?;
         }
         self.result.write_str(" ")?;
-        self.print_bytes(section.data())?;
+        if self.config.print_skeleton {
+            self.result.write_str("...")?;
+        } else {
+            self.print_bytes(section.data())?;
+        }
         self.end_group()?;
         Ok(())
     }


Test patch:
diff --git a/tests/cli/print-skeleton.wat b/tests/cli/print-skeleton.wat
index 809615cf..3785c59a 100644
--- a/tests/cli/print-skeleton.wat
+++ b/tests/cli/print-skeleton.wat
@@ -6,4 +6,5 @@
   (data (i32.const 0) "1234")
   (table 1 funcref)
   (elem (i32.const 0) func $f)
+  (@custom "hello" (after data) "data")
 )
diff --git a/tests/cli/print-skeleton.wat.stdout b/tests/cli/print-skeleton.wat.stdout
index aef078df..ce7fa361 100644
--- a/tests/cli/print-skeleton.wat.stdout
+++ b/tests/cli/print-skeleton.wat.stdout
@@ -5,4 +5,5 @@
   (memory (;0;) 0)
   (elem (;0;) (i32.const 0) ...)
   (data (;0;) (i32.const 0) ...)
+  (@custom "hello" (after data) ...)
 )
Repository: bytecodealliance/wasm-tools
Pull request #1886 (2024-10-30 19:12:01)

Relax semver-checks to compare worlds in packages with different versions
In wasm-tools component semver-checks, instead of requiring that the old and new world live in packages with the same id, just require that they have the same name. This allows checking for semver compatibility between different versions of a package, for example, this command:

```shell
$ wasm-tools component semver-check --prev wasi:http/proxy@0.2.2 --new wasi:http/proxy@0.2.3 ./wit
```

in a dirctory with `wit/deps/http@0.2.2` contains the current wasi-http wit files, and `wit/deps/http@0.2.3` contains a new set of wit files, checks that the new version is semver-compatible.


Patch:
diff --git a/crates/wit-component/src/semver_check.rs b/crates/wit-component/src/semver_check.rs
index 1c4a9f4f..58d0aa74 100644
--- a/crates/wit-component/src/semver_check.rs
+++ b/crates/wit-component/src/semver_check.rs
@@ -55,7 +55,7 @@ pub fn semver_check(mut resolve: Resolve, prev: WorldId, new: WorldId) -> Result
         .package
         .context("new world not in named package")?;
     let new_pkg_name = &resolve.packages[new_pkg_id].name;
-    if old_pkg_id != new_pkg_id {
+    if old_pkg_name != new_pkg_name {
         bail!("the old world is in package {old_pkg_name}, which is not the same as the new world, which is in package {new_pkg_name}", )
     }
 


Test patch:
diff --git a/tests/cli/semver-check-different-package-versions.wit b/tests/cli/semver-check-different-package-versions.wit
new file mode 100644
index 00000000..ff169c1f
--- /dev/null
+++ b/tests/cli/semver-check-different-package-versions.wit
@@ -0,0 +1,14 @@
+// FAIL: component semver-check % --prev a:b/worldly@0.2.0 --new a:b/worldly@0.2.1
+
+package foo:root;
+package a:b@0.2.0 {
+  world worldly {
+    import a: func();
+    import b: interface {}
+  }
+}
+
+package a:b@0.2.1 {
+  world worldly {
+  }
+}
diff --git a/tests/cli/semver-check-different-package-versions.wit.stderr b/tests/cli/semver-check-different-package-versions.wit.stderr
new file mode 100644
index 00000000..07bfece7
--- /dev/null
+++ b/tests/cli/semver-check-different-package-versions.wit.stderr
@@ -0,0 +1,5 @@
+error: new world is not semver-compatible with the previous world
+
+Caused by:
+    0: type mismatch for import `worldly`
+       missing import named `a` (at offset 0x186)
Repository: bytecodealliance/wasm-tools
Pull request #1993 (2025-02-04 13:51:37)

`wast`: fix inline data segment resolution
Fixes https://github.com/bytecodealliance/wasm-tools/issues/1994

Robbepop: CI tests seems to be failing because they are still expecting incorrect `wast` resolution results. Please check if this is correct.
alexcrichton: Yeah that's expected, you can re-run the tests with `BLESS=1` to commit the new copies (and it's expected to see it change as part of this PR)
Robbepop: CI tests are still unhappy but I don't get why. Apparently some `wit-parser` fails with code that is seemingly unrelated to the changes introduced in this PR - at least to my limited knowledge.
Robbepop: I cannot reproduce the CI issue locally. Please help!
alexcrichton: Ok tracked that down to https://github.com/bytecodealliance/wasm-tools/pull/1999, mind rebasing this once that's in?
Robbepop: > Ok tracked that down to #1999, mind rebasing this once that's in?

Ah great! Sure, I am ready. :)

Patch:
diff --git a/crates/wast/src/core/resolve/deinline_import_export.rs b/crates/wast/src/core/resolve/deinline_import_export.rs
index 146c57e0..46d368db 100644
--- a/crates/wast/src/core/resolve/deinline_import_export.rs
+++ b/crates/wast/src/core/resolve/deinline_import_export.rs
@@ -54,7 +54,11 @@ pub fn run(fields: &mut Vec<ModuleField>) {
                         page_size_log2,
                     } => {
                         let len = data.iter().map(|l| l.len()).sum::<usize>() as u64;
-                        let pages = (len + default_page_size() - 1) / default_page_size();
+                        let page_size = match page_size_log2 {
+                            Some(page_size_log2) => 2_u64.pow(page_size_log2),
+                            None => default_page_size(),
+                        };
+                        let pages = (len + page_size - 1) / page_size;
                         let kind = MemoryKind::Normal(MemoryType {
                             limits: Limits {
                                 is64,


Test patch:
diff --git a/tests/snapshots/testsuite/proposals/custom-page-sizes/custom-page-sizes.wast/36.print b/tests/snapshots/testsuite/proposals/custom-page-sizes/custom-page-sizes.wast/36.print
index 1c721ea0..a7cd71ab 100644
--- a/tests/snapshots/testsuite/proposals/custom-page-sizes/custom-page-sizes.wast/36.print
+++ b/tests/snapshots/testsuite/proposals/custom-page-sizes/custom-page-sizes.wast/36.print
@@ -1,7 +1,7 @@
 (module
   (type (;0;) (func (result i32)))
   (type (;1;) (func (param i32) (result i32)))
-  (memory (;0;) 1 1 (pagesize 0x1))
+  (memory (;0;) 3 3 (pagesize 0x1))
   (export "size" (func 0))
   (export "grow" (func 1))
   (export "load" (func 2))
Repository: bytecodealliance/wasm-tools
Pull request #2053 (2025-02-14 17:47:20)

Fix importing a stable resource as unstable
This fixes a regression from #2046 identified in #1995


Patch:
diff --git a/crates/wit-parser/src/resolve.rs b/crates/wit-parser/src/resolve.rs
index 8646f77a..e2c05d88 100644
--- a/crates/wit-parser/src/resolve.rs
+++ b/crates/wit-parser/src/resolve.rs
@@ -2885,7 +2885,13 @@ impl Remap {
         self.process_foreign_types(unresolved, pkgid, resolve)?;
 
         for (id, span) in unresolved.required_resource_types.iter() {
-            let mut id = self.map_type(*id, Some(*span))?;
+            // Note that errors are ignored here because an error represents a
+            // type that has been configured away. If a type is configured away
+            // then any future use of it will generate an error so there's no
+            // need to validate that it's a resource here.
+            let Ok(mut id) = self.map_type(*id, Some(*span)) else {
+                continue;
+            };
             loop {
                 match resolve.types[id].kind {
                     TypeDefKind::Type(Type::Id(i)) => id = i,


Test patch:
diff --git a/crates/wit-parser/tests/ui/unstable-resource.wit b/crates/wit-parser/tests/ui/unstable-resource.wit
new file mode 100644
index 00000000..66b9beb0
--- /dev/null
+++ b/crates/wit-parser/tests/ui/unstable-resource.wit
@@ -0,0 +1,17 @@
+package a:b@0.1.0;
+
+interface foo {
+  @unstable(feature = inactive)
+  use wasi:io/error@0.1.0.{error};
+
+  @unstable(feature = inactive)
+  x: func(y: borrow<error>);
+}
+
+package wasi:io@0.1.0 {
+  interface error {
+    resource error;
+  }
+}
+
+
diff --git a/crates/wit-parser/tests/ui/unstable-resource.wit.json b/crates/wit-parser/tests/ui/unstable-resource.wit.json
new file mode 100644
index 00000000..3d6677a4
--- /dev/null
+++ b/crates/wit-parser/tests/ui/unstable-resource.wit.json
@@ -0,0 +1,44 @@
+{
+  "worlds": [],
+  "interfaces": [
+    {
+      "name": "error",
+      "types": {
+        "error": 0
+      },
+      "functions": {},
+      "package": 0
+    },
+    {
+      "name": "foo",
+      "types": {},
+      "functions": {},
+      "package": 1
+    }
+  ],
+  "types": [
+    {
+      "name": "error",
+      "kind": "resource",
+      "owner": {
+        "interface": 0
+      }
+    }
+  ],
+  "packages": [
+    {
+      "name": "wasi:io@0.1.0",
+      "interfaces": {
+        "error": 0
+      },
+      "worlds": {}
+    },
+    {
+      "name": "a:b@0.1.0",
+      "interfaces": {
+        "foo": 1
+      },
+      "worlds": {}
+    }
+  ]
+}
\ No newline at end of file