coral-xyz / anchor-book

The Anchor Book
https://book.anchor-lang.com
Apache License 2.0
97 stars 59 forks source link

Syntax Error Due to Missing Semicolon in PDAs.md #97

Closed hiroyukikumazawa closed 7 months ago

hiroyukikumazawa commented 7 months ago

Hello,

I've encountered a syntax error in the game module within the anchor_in_depth/PDAs.md file. Specifically, the issue arises from a missing semicolon at the end of the line where user_stats.bump is assigned. Here's the relevant code snippet:

use anchor_lang::prelude::*;

declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");

#[program]
pub mod game {
    use super::*;
    // handler function
    pub fn create_user_stats(ctx: Context<CreateUserStats>, name: String) -> Result<()> {
        let user_stats = &mut ctx.accounts.user_stats;
        user_stats.level = 0;
        if name.as_bytes().len() > 200 {
            // proper error handling omitted for brevity
            panic!();
        }
        user_stats.name = name;
        user_stats.bump = ctx.bumps.user_stats // Missing semicolon here

Issue: The line user_stats.bump = ctx.bumps.user_stats is missing a semicolon at the end. This omission could lead to a compilation error, affecting developers who are trying to compile or run this example.

Expected Correction: The line should end with a semicolon, as shown below:

user_stats.bump = ctx.bumps.user_stats;

Recommendation: Please add the missing semicolon to ensure the code snippet compiles without errors. This small fix will help improve the documentation's accuracy and usability for developers exploring Anchor.

Thank you for your attention to this matter.