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

Type Integer does not support signed comparisons #1386

Closed
WeeknightMVP opened this issue Jul 15, 2022 · 1 comment
Closed

Type Integer does not support signed comparisons #1386

WeeknightMVP opened this issue Jul 15, 2022 · 1 comment

Comments

@WeeknightMVP
Copy link

$ docker run --rm -it ghcr.io/galoisinc/cryptol:nightly
┏━╸┏━┓╻ ╻┏━┓╺┳╸┏━┓╻
┃  ┣┳┛┗┳┛┣━┛ ┃ ┃ ┃┃
┗━╸╹┗╸ ╹ ╹   ╹ ┗━┛┗━╸
version 2.13.0.99
https://cryptol.net  :? for help

Loading module Cryptol
Cryptol> (-3:Integer) <$ 5

[error] at <interactive>:1:1--1:18:
  • Type `Integer` does not support signed comparisons.
      arising from
      use of expression (<$)
      at <interactive>:1:1--1:18

Should it?

@WeeknightMVP
Copy link
Author

> :h <$

    (<$) : {a} (SignedCmp a) => a -> a -> Bit

Precedence 30, does not associate.

2's complement signed less-than.

Integers are not "2's complement".

Cryptol> :h <

type constraint i < j = j >= 1 + i

Assert that the first numeric type is less than the second.

            ---------

    (<) : {a} (Cmp a) => a -> a -> Bit

Precedence 30, does not associate.

Less-than. Only works on comparable arguments.

Bitvectors are compared using unsigned arithmetic.

Integers are not bitvectors, so comparison is not "unsigned" and the type constraint applies. Makes sense.

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

No branches or pull requests

1 participant