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

Identically named structs cause failure when parsing seeds for the IDL #2442

Closed
RuvendeGroote opened this issue Mar 22, 2023 · 2 comments
Closed
Labels
bug Something isn't working idl related to the IDL, either program or client side

Comments

@RuvendeGroote
Copy link
Contributor

Hi,

related to, but not identical to, issue #2441, running anchor build on following program

use anchor_lang::prelude::*;

declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");

#[program]
pub mod bug {
    use super::*;

    pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
        ctx.accounts.something.first = 0;
        Ok(())
    }
}

#[derive(Accounts)]
pub struct Initialize<'info> {
    #[account(
        seeds = [&something.first.to_le_bytes()],
        bump
    )]
    pub something: Account<'info, Something>,
}

#[account]
pub struct Something {
    pub first: u64,
}

mod other {
    use anchor_lang::prelude::*;

    #[derive(AnchorDeserialize, AnchorSerialize)]
    pub struct Something {
        pub second: u64,
    }
}

results in

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', lang/syn/src/idl/pda.rs:336:22`

Tested with 0.26.0 and 0.27.0.

@RuvendeGroote
Copy link
Contributor Author

you have to turn on the seeds feature first of course

@acheroncrypto acheroncrypto added the idl related to the IDL, either program or client side label Sep 26, 2023
@acheroncrypto acheroncrypto mentioned this issue Feb 25, 2024
@acheroncrypto acheroncrypto added the bug Something isn't working label Mar 10, 2024
@acheroncrypto
Copy link
Collaborator

Fixed in #2824.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working idl related to the IDL, either program or client side
Projects
None yet
Development

No branches or pull requests

2 participants