Skip to content

Library serialization does not preserve procedure attributes #2608

@Farukest

Description

@Farukest

Packages versions

miden-assembly: 0.20.2
miden-mast-package: 0.20.2

Bug description

Procedure attributes (e.g., @note_script) are correctly parsed and stored during library compilation, but they are lost after serialization/deserialization using Library::write_to_file() and Library::read_from_bytes().

This issue was discovered while implementing miden-base#2339, which requires finding procedures with @note_script attribute in serialized libraries.

How can this be reproduced?

  1. Create a MASM file with a procedure annotation:
@note_script
pub proc main
    push.1 drop
end
  1. Compile to library and check attributes:
let lib = assembler.assemble_library_from_dir(&dir, namespace)?;
for export in lib.exports() {
    if let Some(proc) = export.as_procedure() {
        println!("BEFORE: {:?}", proc.attributes);
        // Output: {"note_script": "None"}
    }
}
  1. Serialize and deserialize:
lib.write_to_file(&path)?;
let lib2 = Library::read_from_bytes(&std::fs::read(&path)?)?;
for export in lib2.exports() {
    if let Some(proc) = export.as_procedure() {
        println!("AFTER: {:?}", proc.attributes);
        // Output: {} (empty)
    }
}

Expected: Attributes preserved
Actual: Attributes empty

Relevant log output

Metadata

Metadata

Assignees

Labels

assemblyRelated to Miden assembly

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions