Skip to content

Commit

Permalink
lang: fix missing account name info when deser fails when using 'init…
Browse files Browse the repository at this point in the history
…' or 'zero' (#1800)
  • Loading branch information
paul-schaaf authored Apr 20, 2022
1 parent 765fee0 commit d0a13e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The minor version will be incremented upon a breaking change and the patch versi
### Fixes

* cli: Move `overflow-checks` into workspace `Cargo.toml` so that it will not be ignored by compiler ([#1806](https://github.com/project-serum/anchor/pull/1806)).
* lang: Fix missing account name information when deserialization fails when using `init` or `zero` ([#1800](https://github.com/project-serum/anchor/pull/1800)).

## [0.24.2] - 2022-04-13

Expand Down
17 changes: 9 additions & 8 deletions lang/syn/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ impl Field {
checked: bool,
) -> proc_macro2::TokenStream {
let field = &self.ident;
let field_str = field.to_string();
let container_ty = self.container_ty();
let owner_addr = match &kind {
None => quote! { program_id },
Expand All @@ -307,13 +308,13 @@ impl Field {
quote! {
#container_ty::try_from(
&#field,
)?
).map_err(|e| e.with_account_name(#field_str))?
}
} else {
quote! {
#container_ty::try_from_unchecked(
&#field,
)?
).map_err(|e| e.with_account_name(#field_str))?
}
};
if *boxed {
Expand All @@ -329,13 +330,13 @@ impl Field {
quote! {
#container_ty::try_from(
&#field,
)?
).map_err(|e| e.with_account_name(#field_str))?
}
} else {
quote! {
#container_ty::try_from_unchecked(
&#field,
)?
).map_err(|e| e.with_account_name(#field_str))?
}
}
}
Expand All @@ -344,14 +345,14 @@ impl Field {
quote! {
#container_ty::try_from(
&#field,
)?
).map_err(|e| e.with_account_name(#field_str))?
}
} else {
quote! {
#container_ty::try_from_unchecked(
#owner_addr,
&#field,
)?
).map_err(|e| e.with_account_name(#field_str))?
}
}
}
Expand All @@ -361,14 +362,14 @@ impl Field {
#container_ty::try_from(
#owner_addr,
&#field,
)?
).map_err(|e| e.with_account_name(#field_str))?
}
} else {
quote! {
#container_ty::try_from_unchecked(
#owner_addr,
&#field,
)?
).map_err(|e| e.with_account_name(#field_str))?
}
}
}
Expand Down

0 comments on commit d0a13e6

Please sign in to comment.