Skip to content

Conversation

@sewqasreedas
Copy link
Contributor

@sewqasreedas sewqasreedas commented Nov 26, 2025

The doc example for append_byte was using append_byte(0) and asserting equality with "0", which would never be true.

append_byte(0) adds a NULL byte (0x00), not the character '0' (0x30). The assert would always fail since the byte array would contain a null character, not the string "0".

Fixed by using the char literal 'A' which is more readable and idiomatic.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orizi reviewed all commit messages.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion


corelib/src/byte_array.cairo line 182 at r1 (raw file):

    /// let mut ba = "";
    /// ba.append_byte(0x41); // Appending a single byte 'A'
    /// assert!(ba == "A");

Suggestion:

    /// ba.append_byte('A'); // Appending a single byte 'A'
    /// assert!(ba == "A");

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion


corelib/src/byte_array.cairo line 182 at r1 (raw file):

    /// let mut ba = "";
    /// ba.append_byte(0x41); // Appending a single byte 'A'
    /// assert!(ba == "A");

Suggestion:

    /// let mut ba = "";
    /// ba.append_byte('A');
    /// assert!(ba == "A");

@sewqasreedas sewqasreedas force-pushed the fix/byte-array-doc-example branch from b2fbbb6 to 997e3c2 Compare November 27, 2025 09:02
@sewqasreedas sewqasreedas requested a review from orizi November 27, 2025 09:03
Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@orizi reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @sewqasreedas)

@orizi orizi enabled auto-merge November 27, 2025 12:55
@orizi orizi added this pull request to the merge queue Nov 27, 2025
Merged via the queue into starkware-libs:main with commit 97cb274 Nov 27, 2025
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants