Skip to content

Commit

Permalink
add duplication check
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Jun 5, 2024
1 parent a049470 commit 83cb42b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crates/types/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@ impl ModuleBundle {

let ModuleBundle { codes } = self;
for (cm, m) in compiled_modules.iter().zip(codes.into_iter()) {
map.insert(cm.self_id(), (m.code, cm));
if map.insert(cm.self_id(), (m.code, cm)).is_some() {
return Err(
PartialVMError::new(StatusCode::DUPLICATE_MODULE_NAME).with_message(format!(
"Duplicate module name found: {}",
cm.self_id().name()
)),
);
}
}

let mut order = vec![];
Expand Down

0 comments on commit 83cb42b

Please sign in to comment.