Skip to content

Commit a1dd9ec

Browse files
authored
Merge branch 'main' into snapshot-use-tempfile
2 parents 1eed458 + f32cd2c commit a1dd9ec

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

soroban-sdk-macros/src/derive_event.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ fn derive_impls(args: &ContractEventArgs, input: &DeriveInput) -> Result<TokenSt
163163
.collect::<Vec<_>>();
164164

165165
// If errors have occurred, return them.
166-
let errors = errors.checkpoint()?;
166+
let mut errors = errors.checkpoint()?;
167167

168168
// Generated code spec.
169169
let export = args.export.unwrap_or(true);
@@ -266,10 +266,17 @@ fn derive_impls(args: &ContractEventArgs, input: &DeriveInput) -> Result<TokenSt
266266
DataFormat::SingleValue if data_params_count == 0 => quote! {
267267
#path::Val::VOID.to_val()
268268
},
269-
DataFormat::SingleValue => quote! {
270-
use #path::IntoVal;
271-
#(self.#data_idents.into_val(env))*
272-
},
269+
DataFormat::SingleValue => {
270+
if data_params_count > 1 {
271+
errors.push(Error::custom(
272+
"data_format = \"single-value\" requires exactly 0 or 1 data fields, but found more",
273+
));
274+
}
275+
quote! {
276+
use #path::IntoVal;
277+
#(self.#data_idents.into_val(env))*
278+
}
279+
}
273280
DataFormat::Vec if data_params_count == 0 => quote! {
274281
use #path::IntoVal;
275282
#path::Vec::<#path::Val>::new(env).into_val(env)

0 commit comments

Comments
 (0)