Skip to content

Commit

Permalink
fix: relax the module name validation in ConvertHirToMasm to support …
Browse files Browse the repository at this point in the history
…the Wasm CM naming
  • Loading branch information
greenhat committed Nov 29, 2024
1 parent ce9f1e0 commit 2b71558
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions codegen/masm/src/convert.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use miden_assembly::LibraryPath;
use miden_assembly::{ast, LibraryNamespace, LibraryPath, Span};
use midenc_hir::{
self as hir,
pass::{AnalysisManager, ConversionPass, ConversionResult},
Expand Down Expand Up @@ -108,8 +108,15 @@ impl ConversionPass for ConvertHirToMasm<hir::Module> {
} else {
ModuleKind::Library
};
let name = LibraryPath::new(&module.name).unwrap_or_else(|err| {
panic!("invalid module name '{}': {}", module.name.as_str(), err)
let name = LibraryPath::new(&module.name).unwrap_or_else(|_| {
// Fallback for Wasm CM naming `namespace:package/interface@version`
LibraryPath::new_from_components(
LibraryNamespace::Anon,
[ast::Ident::new_unchecked(Span::new(
module.name.span,
module.name.as_str().into(),
))],
)
});
let mut masm_module = Box::new(masm::Module::new(name, kind));

Expand Down

0 comments on commit 2b71558

Please sign in to comment.