Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lang: fix missing account name info when deser fails when using 'init' or 'zero' #1800

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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