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

Add int_range_try_new libfunc. #6288

Merged
merged 1 commit into from
Aug 28, 2024
Merged

Conversation

liorgold2
Copy link
Collaborator

@liorgold2 liorgold2 commented Aug 26, 2024

Stack:

⚠️ Part of a stack created by spr. Do not merge manually using the UI - doing so may have unexpected results.


This change is Reviewable

@liorgold2 liorgold2 force-pushed the pr/liorgold2/lior/range1/d8aa7059 branch from 64103f0 to e3e3115 Compare August 26, 2024 19:09
@liorgold2 liorgold2 force-pushed the pr/liorgold2/lior/range1/12946952 branch from a7707f6 to 95ccbe1 Compare August 26, 2024 19:09
@liorgold2 liorgold2 requested a review from orizi August 27, 2024 10:44
Copy link
Collaborator Author

@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: 0 of 6 files reviewed, 1 unresolved discussion (waiting on @orizi)


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

                },
                // Failure.
                BranchSignature {

I wonder if I should return the range [y, y] in the failure branch. Currently, the high level code looks like:

        match internal::range_try_new(self.start, self.end) {
            Option::Some(range) => range,
            Option::None => internal::range_try_new(self.end, self.end).unwrap(),
        }

Note the unwrap() which makes it panicable (unnecessarily).

The two ways to solve it (if we want to) are:

  1. Return the range [y, y] on failure.
  2. Add another libfunc for constructing an empty range [a, a] (which never fails)

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.

Reviewed all commit messages.
Reviewable status: 0 of 6 files reviewed, 1 unresolved discussion (waiting on @liorgold2)


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

Previously, liorgold2 wrote…

I wonder if I should return the range [y, y] in the failure branch. Currently, the high level code looks like:

        match internal::range_try_new(self.start, self.end) {
            Option::Some(range) => range,
            Option::None => internal::range_try_new(self.end, self.end).unwrap(),
        }

Note the unwrap() which makes it panicable (unnecessarily).

The two ways to solve it (if we want to) are:

  1. Return the range [y, y] on failure.
  2. Add another libfunc for constructing an empty range [a, a] (which never fails)

making Range constable makes sense as well.

but returning it in the Result::Err makes sense to me (as it actually costs nothing).

but if we add it as constable we can than just (One::one(), One::one()) or something like it.

@liorgold2 liorgold2 force-pushed the pr/liorgold2/lior/range1/d8aa7059 branch from e3e3115 to fa75e7f Compare August 27, 2024 14:24
@liorgold2 liorgold2 force-pushed the pr/liorgold2/lior/range1/12946952 branch from 95ccbe1 to be1999d Compare August 27, 2024 14:24
@liorgold2 liorgold2 changed the title Add range_try_new libfunc. Add int_range_try_new libfunc. Aug 27, 2024
@liorgold2 liorgold2 force-pushed the pr/liorgold2/lior/range1/d8aa7059 branch from fa75e7f to b90055d Compare August 27, 2024 17:03
@liorgold2 liorgold2 force-pushed the pr/liorgold2/lior/range1/12946952 branch from be1999d to c392a11 Compare August 27, 2024 17: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.

Reviewed 4 of 5 files at r3, all commit messages.
Reviewable status: 4 of 6 files reviewed, 1 unresolved discussion (waiting on @liorgold2)

@liorgold2 liorgold2 force-pushed the pr/liorgold2/lior/range1/12946952 branch from c392a11 to d798244 Compare August 27, 2024 18:55
@liorgold2 liorgold2 force-pushed the pr/liorgold2/lior/range1/d8aa7059 branch from b90055d to 34e0a0b Compare August 27, 2024 18:55
Copy link
Collaborator Author

@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: 4 of 6 files reviewed, 1 unresolved discussion (waiting on @orizi)


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

Previously, orizi wrote…

making Range constable makes sense as well.

but returning it in the Result::Err makes sense to me (as it actually costs nothing).

but if we add it as constable we can than just (One::one(), One::one()) or something like it.

I went with returning [y, y) or failure as this is the simplest solution.
Done in another PR.

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:

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

@liorgold2 liorgold2 changed the base branch from pr/liorgold2/lior/range1/12946952 to main August 28, 2024 08:11
@liorgold2 liorgold2 force-pushed the pr/liorgold2/lior/range1/d8aa7059 branch from 34e0a0b to 130a577 Compare August 28, 2024 08:11
@liorgold2 liorgold2 enabled auto-merge August 28, 2024 08:11
@liorgold2 liorgold2 added this pull request to the merge queue Aug 28, 2024
Merged via the queue into main with commit 98aa21d Aug 28, 2024
87 checks passed
@orizi orizi deleted the pr/liorgold2/lior/range1/d8aa7059 branch September 5, 2024 12:11
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.

2 participants