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

ucm and the LSP do not validate Int (and Nat) for range #4007

Open
kylegoetz opened this issue May 20, 2023 · 2 comments
Open

ucm and the LSP do not validate Int (and Nat) for range #4007

kylegoetz opened this issue May 20, 2023 · 2 comments
Labels
lexer syntax Relates to Unison syntax team-arya

Comments

@kylegoetz
Copy link
Contributor

kylegoetz commented May 20, 2023

Put in a scratch file:

x : Int
x = +922337203685477580745235235252352

UCM will tell you

These new definitions are ok to `add`:
      x : Int

and the LSP in VS Code will also not complain.

However, the docs indicate that Int has a max value of 9223372036854775807. Clearly the x is larger than this. Also when I search for the max value in the Github repo, I do not find a single instance of this value in the parsing code.

Edit The same is true of Nat if you remove the + and redefine to x : Nat

@kylegoetz kylegoetz changed the title ucm and the LSP do not validate Int for range ucm and the LSP do not validate Int (and Nat) for range May 20, 2023
@kylegoetz
Copy link
Contributor Author

kylegoetz commented May 20, 2023

My guess is that it comes down to this code in Pattern.hs,

| Nat loc !Word64

data Pattern loc
  = Unbound loc
  | Var loc
  | Boolean loc !Bool
  | Int loc !Int64
  | Nat loc !Word64
 [snip]
  deriving (Ord, Generic, Functor, Foldable, Traversable)

Edit Or one of the other places in the codebase where Nat is defined as an alias for Word64 and Int for Int64.

@aryairani
Copy link
Contributor

The parser/lexer could load these as a BigInt and check the range

@pchiusano pchiusano added the syntax Relates to Unison syntax label Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lexer syntax Relates to Unison syntax team-arya
Projects
None yet
Development

No branches or pull requests

3 participants