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

Replace num/fromIntegral with witch #203

Merged
merged 1 commit into from Jul 10, 2023
Merged

Replace num/fromIntegral with witch #203

merged 1 commit into from Jul 10, 2023

Conversation

arcz
Copy link
Collaborator

@arcz arcz commented Feb 21, 2023

Description

Closes #155.

Checklist

  • tested locally
  • added automated tests
  • updated the docs
  • updated the changelog

@arcz arcz marked this pull request as draft February 21, 2023 20:31
@arcz arcz changed the title Replace num with witch Replace num/fromIntegral with witch May 25, 2023
@msooseth
Copy link
Collaborator

@arcz This seems a bit outdated now. Do you think it's worth trying to resolve the conflicts and merging?

@arcz
Copy link
Collaborator Author

arcz commented Jun 21, 2023

@msooseth I'll rebase and finish it

@arcz arcz force-pushed the witch branch 4 times, most recently from b184754 to c4df3db Compare June 30, 2023 22:33
@arcz arcz marked this pull request as ready for review June 30, 2023 22:34
@arcz arcz requested a review from d-xo June 30, 2023 22:34
@arcz
Copy link
Collaborator Author

arcz commented Jun 30, 2023

This doesn't fix all the occurrences of fromIntegral, also now there are many unsafeInto. Some of those were hard to fix, that's why I left them as is, but at least those places are explicit now. I think we can merge this at this stage already and work on the remaining cases later on.

len = num $ word $ slice 1 pre bs
x | 192 <= x && x < 248 -> (1, num $ x - 192, True, True) -- short list
where pre = into $ x - 183
len = fromIntegral $ word $ slice 1 pre bs
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not unsafeInto?

assertRead (idx, Lit sz, buf) = fmap (\s -> PImpl (PGEq idx (bufLength buf)) (PEq (ReadByte idx buf) (LitByte (num s)))) [(0::Int)..num sz-1]
assertRead (idx, Lit sz, buf) =
fmap
-- TODO: unsafeInto instead fromIntegral here makes symbolic tests fail
Copy link
Collaborator

Choose a reason for hiding this comment

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

interesting! can you file a bug for this?

Copy link
Collaborator

@d-xo d-xo left a comment

Choose a reason for hiding this comment

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

Looks great! I think having an exception on overflow is already a very big improvement compared to silent truncation. Just one small question

@arcz arcz merged commit d564592 into ethereum:main Jul 10, 2023
4 checks passed
@arcz arcz deleted the witch branch July 10, 2023 10:22
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.

Eliminate fromIntegral
3 participants