Skip to content

Commit f0dda99

Browse files
authored
Introducing the bigint (#6670)
* add primitive bigint * Js_bigint adding operations * Js_json adding support of bigint * rename test * remove bigint from Js_json * stale comment * remove unnecessary guard in pattern matching * fix literal_overlaps * primitive bigint instead of Js_bigint.t * variant coercion for bigint * add error test * add optimization of comparisons * add bigint_test and binding bigint methods, NaN, etc * stale comment * add bigint pow operator * clean up Js_exp for bigint operations * remove isNaN, isInfinite * remove NaN from BigInt * fix compare function * fix test * add bitwise operations * eta conversion for bigint * optimization * bitwise operators in Js_bigint * add test for bitwise operations * remove bigint operators from parser and pervasives * rebase clean up * update change log * fix incorrect compare bigint values * remove leftover * removed leftover * handling and testing bigint values with leading zeros and minus * remove optimization const_compare from parmatch and add test * add tests for pattern matching bigint liternal * support only decimal bigint literal and pattern matching * fix test * handle delimiter '_' * throw Division_by_zero in bigint div, mod * call runtime only when dividing by zero * fix incorrect dividing by zero with non constant * remove is_safe from Pdivbigint, Pmodbigint * stale comments * fix bigint_utils.compare * change bigint model to sign * string * clean up
1 parent c8c4b3a commit f0dda99

File tree

98 files changed

+1158
-116
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+1158
-116
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
1313
# 11.1.0-rc.6 (Unreleased)
1414

15+
#### :rocket: New Feature
16+
17+
- Add the primitive bigint type https://github.com/rescript-lang/rescript-compiler/pull/6670
18+
1519
#### :bug: Bug Fix
1620

1721
- Fix mishandling of uncurried functions in super errors. https://github.com/rescript-lang/rescript-compiler/pull/6694
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
Warning number 11
3+
/.../fixtures/bigint_match_literal.res:3:3-4
4+
5+
1 │ let m1 = switch 1n {
6+
2 │ | 0001n => 1
7+
3 │ | 1n => 1
8+
4 │ | -0001n => -1
9+
5 │ | _ => 0
10+
11+
this match case is unused.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
We've found a bug for you!
3+
/.../fixtures/variant_coercion_bigint.res:5:10-20
4+
5+
3 │ let x = One(true)
6+
4 │
7+
5 │ let y = (x :> bigint)
8+
6 │
9+
10+
Type x is not a subtype of bigint
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
We've found a bug for you!
3+
/.../fixtures/variant_coercion_bigint_as.res:5:10-20
4+
5+
3 │ let x = One
6+
4 │
7+
5 │ let y = (x :> bigint)
8+
6 │
9+
10+
Type x is not a subtype of bigint

jscomp/build_tests/super_errors/expected/warnings4.res.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
14 │
1111

1212
You forgot to handle a possible case here, for example:
13-
| #second(_) | #fourth | #third
13+
| #second(_) | #fourth | #third

jscomp/build_tests/super_errors/expected/warnings5.res.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,4 @@ Either bind these labels explicitly or add ', _' to the pattern.
187187
60 │
188188

189189
You forgot to handle a possible case here, for example:
190-
| (_, true)
190+
| (_, true)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
let m1 = switch 1n {
2+
| 0001n => 1
3+
| 1n => 1
4+
| -0001n => -1
5+
| _ => 0
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
type x = | @as(1n) One(bool) | @as(2n) Two
2+
3+
let x = One(true)
4+
5+
let y = (x :> bigint)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
type x = | @as(1n) One | Two
2+
3+
let x = One
4+
5+
let y = (x :> bigint)

jscomp/core/js_analyzer.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ let rec eq_expression ({ expression_desc = x0 } : J.expression)
158158
| Undefined x -> y0 = Undefined x
159159
| Number (Int { i }) -> (
160160
match y0 with Number (Int { i = j }) -> i = j | _ -> false)
161+
| Number (Bigint {positive = p0; value = v0}) -> (
162+
match y0 with Number (Bigint {positive = p1; value = v1}) -> p0 = p1 && v0 = v1 | _ -> false)
161163
| Number (Float _) -> false
162164
(* begin match y0 with
163165
| Number (Float j) ->

0 commit comments

Comments
 (0)