wasm: fix panic on empty Struct expression

This commit is contained in:
Brian Carroll 2022-03-04 20:43:58 +00:00
parent 28a3ae85e3
commit 1afada4075

View file

@ -936,11 +936,13 @@ impl<'a> WasmBackend<'a> {
}
_ => internal_error!("Cannot create struct {:?} with storage {:?}", sym, storage),
};
} else {
} else if !fields.is_empty() {
// Struct expression but not Struct layout => single element. Copy it.
let field_storage = self.storage.get(&fields[0]).to_owned();
self.storage
.clone_value(&mut self.code_builder, storage, &field_storage, fields[0]);
} else {
// Empty record. Nothing to do.
}
}