Search code examples
reasonbucklescript

Why can't I assign a 64bit integer to this field?


Is there a numeric suffix I should be using to assign a numerical constant value to an int64 type?

A moderately editted version of the error is:

We've found a bug for you!
{file}.re:321:20-31

321 │ let (rsid:int64) = 180785985722;

This has type: int
Somewhere wanted: int64

Where 'this' is referring to the number highlighted in red.


Solution

  • int64 literals use the suffix L:

    let rsid: int64 = 180785985722L;
    

    I don't think this is documented for Reason anywhere, but it is documented for OCaml, in the manual and the Int64 module, which Reason tends to follow unless there's reason to deviate.