Composing labelled (`implements`) imports of one interface gives output wit-parser panics on
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
The panic is in the wit-parser dependency (decoding.rs:797 asserts prev.is_none()), but the fix belongs in wac-graph's CompositionGraph::encode, which currently gives every labelled (implements "I") import one shared instance type. Build the issue's reproduction (a consumer importing the same interface that defines a type under primary and backup), then trace where encode interns and emits instance types, covering both the implicit-import path and explicit CompositionGraph::import nodes. Done is the repro's final wit_parser::decoding::decode(&composed) succeeding, with one instance type per labelled import as wit-component encodes it.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
When a composition has several (implements "I") imports of the same interface, CompositionGraph::encode gives them all one instance type:
(import "primary" (implements "test:test/logger") (instance (;0;) (type 0)))
(import "backup" (implements "test:test/logger") (instance (;1;) (type 0)))
Several labels for one interface is the case labelled imports exist for (#200). This happens:
- through implicit imports (an instantiated component's labelled imports left unsatisfied);
- through explicit
CompositionGraph::importnodes.
The output validates, and wasmtime runs it. But when the interface defines a type, wit-parser's decoder panics on it, and so does every tool built on that decoder:
wasm-tools component wit;- wit-bindgen;
- jco.
jco transpileaborts the same way (it uses wit-parser 0.259), so the composition can't be run in JavaScript.
The input component decodes fine: it's wit-component's shape, with one instance type per labelled import. Only wac's output has the shared type.
Reproduction
Cargo.toml:
[package]
name = "wac-implements-repro"
version = "0.1.0"
edition = "2024"
[dependencies]
wac-graph = "=0.12.0"
wit-parser = "=0.258.0"
wat = "1"
src/main.rs:
use wac_graph::{types::Package, CompositionGraph, EncodeOptions};
/// A component importing one interface, which defines a type, under two
/// labels: the shape wit-component produces (one instance type per import).
const CONSUMER: &str = r#"
(component
(type (instance
(type (enum "debug" "info"))
(export "level" (type (eq 0)))
(type (func (param "level" 1) (param "message" string)))
(export "log" (func (type 2)))))
(import "primary" (implements "test:test/logger") (instance (type 0)))
(type (instance
(type (enum "debug" "info"))
(export "level" (type (eq 0)))
(type (func (param "level" 1) (param "message" string)))
(export "log" (func (type 2)))))
(import "backup" (implements "test:test/logger") (instance (type 1)))
)
"#;
fn main() {
let consumer = wat::parse_str(CONSUMER).unwrap();
// The input decodes fine.
wit_parser::decoding::decode(&consumer).expect("the consumer decodes");
println!("consumer: decodes");
let mut graph = CompositionGraph::new();
let package = Package::from_bytes("test:consumer", None, consumer, graph.types_mut()).unwrap();
let package = graph.register_package(package).unwrap();
graph.instantiate(package);
let composed = graph.encode(EncodeOptions::default()).unwrap();
println!("composed: {} bytes, validated by wac", composed.len());
// The composition does not: wit-parser panics.
wit_parser::decoding::decode(&composed).expect("the composition decodes");
println!("composition: decodes");
}
Output:
consumer: decodes
composed: 348 bytes, validated by wac
thread 'main' panicked at wit-parser-0.258.0/src/decoding.rs:797:29:
assertion failed: prev.is_none()
Expected
The composition decodes as the input does: each labelled import has its own instance type, as wit-component encodes it.
Related
- bytecodealliance/wasm-tools#2506
- Ngôn ngữ chính
- Rust
- Star
- 206
- Fork
- 42
- Merge trung bình
- 4 ngày 9 phút
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của bytecodealliance/wac
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
bytecodealliance/wac#181 · 7 reaction ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
bytecodealliance/wac#170 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
bytecodealliance/wac#169 ·
-
Resolve import loop with ``use``Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
bytecodealliance/wac#166 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
bytecodealliance/wac#165 ·
Tất cả issue của bytecodealliance/wac
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
app enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
elodin-sys/elodin#890 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
guidance-ai/llguidance#391 ·