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

Orizi/dict felt252 for bool and non copy nullable #4340

Merged

Conversation

orizi
Copy link
Collaborator

@orizi orizi commented Nov 1, 2023

This change is Reviewable

Copy link
Contributor

@gilbens-starkware gilbens-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 10 of 11 files at r1, all commit messages.
Reviewable status: 10 of 11 files reviewed, 1 unresolved discussion (waiting on @liorgold2, @orizi, and @spapinistarkware)


crates/cairo-lang-sierra/src/extensions/modules/felt252_dict.rs line 76 at r1 (raw file):

                    info.zero_sized
                })
        }

Add doc. It's not that clear why the first arg is skipped and why at most 3 args.

Code quote:

        id if id == EnumType::id() => {
            generic_args.len() <= 3
                && generic_args.into_iter().skip(1).all(|arg| {
                    let GenericArg::Type(ty) = arg else {
                        return false;
                    };
                    let Ok(info) = context.get_type_info(ty) else {
                        return false;
                    };
                    info.zero_sized
                })
        }

@orizi orizi force-pushed the orizi/dict-felt252-for-bool-and-non-copy-nullable branch from 93f7da5 to b26017f Compare November 2, 2023 10:05
Copy link
Collaborator Author

@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: 10 of 11 files reviewed, 1 unresolved discussion (waiting on @gilbens-starkware, @liorgold2, and @spapinistarkware)


crates/cairo-lang-sierra/src/extensions/modules/felt252_dict.rs line 76 at r1 (raw file):

Previously, gilbens-starkware (Gil Ben-Shachar) wrote…

Add doc. It's not that clear why the first arg is skipped and why at most 3 args.

Done.

Copy link
Contributor

@gilbens-starkware gilbens-starkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

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

Copy link
Collaborator

@liorgold2 liorgold2 left a comment

Choose a reason for hiding this comment

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

Reviewed 9 of 11 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @orizi and @spapinistarkware)


crates/cairo-lang-sierra/src/extensions/modules/felt252_dict.rs line 67 at r2 (raw file):

        id if id == EnumType::id() => {
            // Enums with 2 or less variant has variant indicator 0 as a valid indicator.
            // (the additional arg is the user type).
// Zero is not a valid value for enums with 3 or more variants, so they cannot be used in a dict (whose default value is zero).

Code quote:

            // Enums with 2 or less variant has variant indicator 0 as a valid indicator.
            // (the additional arg is the user type).

Copy link
Collaborator

@liorgold2 liorgold2 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: all files reviewed, 2 unresolved discussions (waiting on @orizi and @spapinistarkware)


crates/cairo-lang-sierra/src/extensions/modules/felt252_dict.rs line 69 at r2 (raw file):

            // (the additional arg is the user type).
            generic_args.len() <= 3
                // All contained types must be 0 size so the size would only be 1.

.

Suggestion:

               // All contained types must be 0-sized, so the total size will be exactly 1.

Copy link
Collaborator

@liorgold2 liorgold2 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: all files reviewed, 3 unresolved discussions (waiting on @orizi and @spapinistarkware)


crates/cairo-lang-sierra/src/extensions/modules/felt252_dict.rs line 68 at r2 (raw file):

            // Enums with 2 or less variant has variant indicator 0 as a valid indicator.
            // (the additional arg is the user type).
            generic_args.len() <= 3

Check len >= 1.

@orizi orizi force-pushed the orizi/dict-felt252-for-bool-and-non-copy-nullable branch from b26017f to 4990c40 Compare November 6, 2023 09:48
@orizi orizi changed the base branch from sierra-minor-update to dev-v2.4.0 November 6, 2023 09:50
Copy link
Collaborator

@liorgold2 liorgold2 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: 9 of 11 files reviewed, 4 unresolved discussions (waiting on @gilbens-starkware, @orizi, and @spapinistarkware)


crates/cairo-lang-sierra/src/extensions/modules/felt252_dict.rs line 42 at r2 (raw file):

}

fn specialize_with_dict_value_param(

Document and mention where it used.

Copy link
Collaborator Author

@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: 9 of 11 files reviewed, 3 unresolved discussions (waiting on @gilbens-starkware, @liorgold2, and @spapinistarkware)


crates/cairo-lang-sierra/src/extensions/modules/felt252_dict.rs line 67 at r2 (raw file):

Previously, liorgold2 wrote…
// Zero is not a valid value for enums with 3 or more variants, so they cannot be used in a dict (whose default value is zero).

Done.


crates/cairo-lang-sierra/src/extensions/modules/felt252_dict.rs line 68 at r2 (raw file):

Previously, liorgold2 wrote…

Check len >= 1.

Done.


crates/cairo-lang-sierra/src/extensions/modules/felt252_dict.rs line 69 at r2 (raw file):

Previously, liorgold2 wrote…

.

Done.

@orizi orizi force-pushed the orizi/dict-felt252-for-bool-and-non-copy-nullable branch from 4990c40 to b2d9f3c Compare November 6, 2023 09:53
Copy link
Collaborator Author

@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: 9 of 11 files reviewed, 4 unresolved discussions (waiting on @gilbens-starkware, @liorgold2, and @spapinistarkware)


crates/cairo-lang-sierra/src/extensions/modules/felt252_dict.rs line 42 at r2 (raw file):

Previously, liorgold2 wrote…

Document and mention where it used.

Done.

Copy link
Collaborator

@liorgold2 liorgold2 left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 1 files at r2, 1 of 2 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @spapinistarkware)

@orizi orizi enabled auto-merge November 6, 2023 09:58
* Enums of size 2 or smaller (to include bool).
* Nullable of `Drop` types, to allow `Nullable<Array<felt252>>`.
* Minor refactoring to allow this, and to merge dict and entry code.
@orizi orizi force-pushed the orizi/dict-felt252-for-bool-and-non-copy-nullable branch from b2d9f3c to 2941502 Compare November 6, 2023 10:00
Copy link
Collaborator Author

@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.

Reviewed 1 of 1 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @spapinistarkware)

@orizi orizi added this pull request to the merge queue Nov 6, 2023
Merged via the queue into dev-v2.4.0 with commit 08d4ddf Nov 6, 2023
37 checks passed
@orizi orizi deleted the orizi/dict-felt252-for-bool-and-non-copy-nullable branch November 6, 2023 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants