Skip to content

Commit 75bd636

Browse files
committed
fix: deserialize LibraryPath for Wasm CM interface named modules
1 parent fe4afa2 commit 75bd636

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

assembly/src/library/path.rs

+21-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use core::{
88
fmt,
99
str::{self, FromStr},
1010
};
11+
use vm_core::debuginfo::SourceSpan;
1112

1213
use smallvec::smallvec;
1314

@@ -503,7 +504,26 @@ impl Deserializable for LibraryPath {
503504
let path = source.read_slice(len)?;
504505
let path =
505506
str::from_utf8(path).map_err(|e| DeserializationError::InvalidValue(e.to_string()))?;
506-
Self::new(path).map_err(|e| DeserializationError::InvalidValue(e.to_string()))
507+
let path = LibraryPath::new(path).unwrap_or_else(|_| {
508+
// Try to parse at least the namespace
509+
match LibraryNamespace::strip_path_prefix(path) {
510+
Ok((ns, rest)) => {
511+
let module_id = Ident::new_unchecked(Span::new(
512+
SourceSpan::default(),
513+
Arc::from(rest.to_string()),
514+
));
515+
LibraryPath::new_from_components(ns, [module_id])
516+
},
517+
Err(_) => {
518+
let module_id = Ident::new_unchecked(Span::new(
519+
SourceSpan::default(),
520+
Arc::from(path.to_string()),
521+
));
522+
LibraryPath::new_from_components(LibraryNamespace::Anon, [module_id])
523+
},
524+
}
525+
});
526+
Ok(path)
507527
}
508528
}
509529

0 commit comments

Comments
 (0)