Skip to content

Commit

Permalink
fix: on Library deserialization, use unchecked constructor for proced…
Browse files Browse the repository at this point in the history
…ure names

The checked constructor fits when parsing MASM code.
The Miden package contains the export names crafted according to the Wasm CM naming scheme
i.e. `namespace:package/interface@version#function`.
Discovered in 0xPolygonMiden/compiler#347
when parsing the Miden package file of the basic wallet account code.
  • Loading branch information
greenhat committed Oct 30, 2024
1 parent 12dd5e5 commit 6d81d65
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions assembly/src/library/mod.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
use alloc::{
collections::{BTreeMap, BTreeSet},
string::{String, ToString},
string::String,
sync::Arc,
vec::Vec,
};

use vm_core::{
crypto::hash::RpoDigest,
debuginfo::Span,
mast::{MastForest, MastNodeId},
utils::{ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable},
Kernel,
};

use crate::ast::{ProcedureName, QualifiedProcedureName};
use crate::ast::{Ident, ProcedureName, QualifiedProcedureName};

mod error;
mod module;
Expand Down Expand Up @@ -180,8 +181,9 @@ impl Deserializable for Library {
for _ in 0..num_exports {
let proc_module = source.read()?;
let proc_name: String = source.read()?;
let proc_name = ProcedureName::new(proc_name)
.map_err(|err| DeserializationError::InvalidValue(err.to_string()))?;
let proc_name = ProcedureName::new_unchecked(Ident::new_unchecked(Span::unknown(
Arc::from(proc_name),
)));
let proc_name = QualifiedProcedureName::new(proc_module, proc_name);
let proc_node_id = MastNodeId::from_u32_safe(source.read_u32()?, &mast_forest)?;

Expand Down

0 comments on commit 6d81d65

Please sign in to comment.