rescript-compiler icon indicating copy to clipboard operation
rescript-compiler copied to clipboard

update message to say that BigInts are supported in @unboxed variants

Open tx46 opened this issue 2 months ago • 5 comments

right now:

@unboxed type t = A(int) | B(int)

gives

This untagged variant definition is invalid: At most one case can be a number type (int or float).

but should probably say:

This untagged variant definition is invalid: At most one case can be a number type (int, float or bigint).

as support was added recently

tx46 avatar Oct 14 '25 03:10 tx46

bigint works natively with @unboxed:

@unboxed
type num = | Float(float) | Int(bigint)

zth avatar Oct 14 '25 12:10 zth

bigint works natively with @unboxed:

@unboxed
type num = | Float(float) | Int(bigint)

yes, the issue here is that the message from the compiler doesn't say that, but it should. :)

tx46 avatar Oct 14 '25 14:10 tx46

This message:

This untagged variant definition is invalid: At most one case can be a number type (int or float).

Means that at most one case can be int or float (which is the JS number type). So you can't mix int and float. But you can mix either float or int with bigint just fine.

I guess one way to make it clearer would be to call it "JavaScript number type" instead of just "number type".

zth avatar Oct 14 '25 14:10 zth

i see, is misinterpreted the message i think and thought it should mention bigint as well, but yeah, doing what you just said would make it a tad clearer i guess.

tx46 avatar Oct 14 '25 15:10 tx46

Open to other suggestions of course as well, if you have any.

zth avatar Oct 14 '25 16:10 zth