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: Support [T; N] in account structs for primitive field T #617

Closed
cherryman opened this issue Aug 16, 2021 · 3 comments
Closed

lang: Support [T; N] in account structs for primitive field T #617

cherryman opened this issue Aug 16, 2021 · 3 comments
Labels

Comments

@cherryman
Copy link
Contributor

No description provided.

@cherryman cherryman changed the title lang: Support [T;N] in account structs for primitive field T lang: Support [T; N] in account structs for primitive field T Aug 16, 2021
@mgild
Copy link
Contributor

mgild commented Aug 23, 2021

Current error

#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize)]
pub struct Array<T, const S: usize> {
    data: [T; S],
    len: usize
}
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: InvalidDigit }', lang/syn/src/idl/mod.rs:162:78
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: <anchor_syn::idl::IdlType as core::str::traits::FromStr>::from_str
   4: <core::iter::adapters::ResultShunt<I,E> as core::iter::traits::iterator::Iterator>::next
   5: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
   6: <core::iter::adapters::ResultShunt<I,E> as core::iter::traits::iterator::Iterator>::next
   7: anchor_syn::idl::file::parse_ty_defs
   8: anchor_syn::idl::file::parse
   9: anchor_cli::build_cwd
  10: anchor_cli::build
  11: anchor_cli::entry
  12: anchor::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@dovahcrow
Copy link

Can we have an attribute attached to a field in the account saying that this field is opaque to idl, e.g. #[idl(skip)] my_field: [T; N]. Although this forbids javascript to read the content of that field, at least we can use generics and const generics in anchor program.

@acheroncrypto
Copy link
Collaborator

Added in #2824.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants