From 239b7119130e18c559971ae3ccda82d10429bf82 Mon Sep 17 00:00:00 2001 From: Paul Schoenfelder Date: Tue, 14 May 2024 05:09:35 -0400 Subject: [PATCH] fix(masm): bypass library path validation for component model identifiers --- codegen/masm/src/masm/function.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/codegen/masm/src/masm/function.rs b/codegen/masm/src/masm/function.rs index d953e5ea..6af9e0ac 100644 --- a/codegen/masm/src/masm/function.rs +++ b/codegen/masm/src/masm/function.rs @@ -141,7 +141,13 @@ impl Function { kind: ast::InvokeKind, target: FunctionIdent, ) { - let path = LibraryPath::new(target.module.as_str()).expect("invalid procedure path"); + let module_name_span = miden_assembly::SourceSpan::new( + target.module.span.start_index().0..target.module.span.end_index().0, + ); + let module_id = ast::Ident::new_unchecked(miden_assembly::Span::new( + module_name_span, + Arc::from(target.module.as_str().to_string().into_boxed_str()), + )); let name_span = miden_assembly::SourceSpan::new( target.function.span.start_index().0..target.function.span.end_index().0, ); @@ -149,6 +155,9 @@ impl Function { name_span, Arc::from(target.function.as_str().to_string().into_boxed_str()), )); + let path = LibraryPath::new(target.module.as_str()).unwrap_or_else(|_| { + LibraryPath::new_from_components(LibraryNamespace::Anon, [module_id]) + }); let name = ast::ProcedureName::new_unchecked(id); self.register_invoked(kind, ast::InvocationTarget::AbsoluteProcedurePath { name, path }); }