Skip to content

Introducing the bigint #6670

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

Merged
merged 45 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1441f59
add primitive bigint
mununki Mar 8, 2024
db001fa
Js_bigint adding operations
mununki Mar 8, 2024
20410da
Js_json adding support of bigint
mununki Mar 8, 2024
2f6217b
rename test
mununki Mar 8, 2024
0b14c33
remove bigint from Js_json
mununki Mar 8, 2024
4f40575
stale comment
mununki Mar 8, 2024
6020820
remove unnecessary guard in pattern matching
mununki Mar 11, 2024
8d95ccd
fix literal_overlaps
mununki Mar 11, 2024
83070a0
primitive bigint instead of Js_bigint.t
mununki Mar 11, 2024
128aa20
variant coercion for bigint
mununki Mar 11, 2024
c1d39b2
add error test
mununki Mar 11, 2024
8835276
add optimization of comparisons
mununki Mar 12, 2024
51e2ab2
add bigint_test and binding bigint methods, NaN, etc
mununki Mar 13, 2024
84cf107
stale comment
mununki Mar 13, 2024
0f21844
add bigint pow operator
mununki Mar 13, 2024
6b01997
clean up Js_exp for bigint operations
mununki Mar 13, 2024
d386c4a
remove isNaN, isInfinite
mununki Mar 15, 2024
bc22261
remove NaN from BigInt
mununki Mar 15, 2024
3b34a01
fix compare function
mununki Mar 15, 2024
d3032e1
fix test
mununki Mar 15, 2024
d3090ff
add bitwise operations
mununki Mar 18, 2024
5683ca2
eta conversion for bigint
mununki Mar 18, 2024
da60074
optimization
mununki Mar 18, 2024
41ba70b
bitwise operators in Js_bigint
mununki Mar 18, 2024
3e9a471
add test for bitwise operations
mununki Mar 19, 2024
fee14cc
remove bigint operators from parser and pervasives
mununki Mar 21, 2024
fc1ea04
rebase clean up
mununki Mar 21, 2024
ec90078
update change log
mununki Mar 21, 2024
b8a5efd
fix incorrect compare bigint values
mununki Mar 21, 2024
79df62c
remove leftover
mununki Mar 21, 2024
dd6b0cf
removed leftover
mununki Mar 22, 2024
9852ad0
handling and testing bigint values with leading zeros and minus
mununki Mar 22, 2024
00d741a
remove optimization const_compare from parmatch and add test
mununki Mar 22, 2024
379dc31
add tests for pattern matching bigint liternal
mununki Mar 22, 2024
990e5ac
support only decimal bigint literal and pattern matching
mununki Mar 23, 2024
0d40dd9
fix test
mununki Mar 23, 2024
79c7013
handle delimiter '_'
mununki Mar 23, 2024
5748e83
throw Division_by_zero in bigint div, mod
mununki Mar 23, 2024
4a43e39
call runtime only when dividing by zero
mununki Mar 23, 2024
e7e41c4
fix incorrect dividing by zero with non constant
mununki Mar 25, 2024
e8e8050
remove is_safe from Pdivbigint, Pmodbigint
mununki Mar 25, 2024
5e963cd
stale comments
mununki Mar 26, 2024
84eecd7
fix bigint_utils.compare
mununki Mar 26, 2024
9652115
change bigint model to sign * string
mununki Mar 26, 2024
d82b4bc
clean up
mununki Mar 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions jscomp/core/js_analyzer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ let rec eq_expression ({ expression_desc = x0 } : J.expression)
| Undefined x -> y0 = Undefined x
| Number (Int { i }) -> (
match y0 with Number (Int { i = j }) -> i = j | _ -> false)
| Number (Bigint { i }) -> (
match y0 with Number (Bigint { i = j }) -> i = j | _ -> false)
| Number (Bigint (s0, i )) -> (
match y0 with Number (Bigint (s1, j)) -> s0 = s1 && i = j | _ -> false)
| Number (Float _) -> false
(* begin match y0 with
| Number (Float j) ->
Expand Down
2 changes: 1 addition & 1 deletion jscomp/core/js_dump.ml
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ and expression_desc cxt ~(level : int) f x : cxt =
Int32.to_string i
(* check , js convention with ocaml lexical convention *)
| Uint i -> Format.asprintf "%lu" i
| Bigint { i } -> Format.asprintf "%sn" i
| Bigint (sign, i) -> Format.asprintf "%sn" (Bigint_utils.to_string sign i)
in
let need_paren =
if s.[0] = '-' then level > 13
Expand Down
10 changes: 7 additions & 3 deletions jscomp/core/js_exp_make.ml
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,9 @@ let obj_int_tag_literal : t =

let int ?comment ?c i : t = { expression_desc = Number (Int { i; c }); comment }

let bigint ?comment i : t = { expression_desc = Number (Bigint { i }); comment}
let bigint ?comment sign i : t = { expression_desc = Number (Bigint (sign, i)); comment}

let zero_bigint_literal : t = {expression_desc = Number (Bigint {i = "0"}); comment = None}
let zero_bigint_literal : t = {expression_desc = Number (Bigint (true, "0")); comment = None}

let small_int i : t =
match i with
Expand Down Expand Up @@ -807,7 +807,11 @@ let tag_type = function
| Ast_untagged_variants.String s -> str s ~delim:DStarJ
| Int i -> small_int i
| Float f -> float f
| Bigint i -> bigint i
| Bigint i ->
let open Bigint_utils in
let sign, i = i |> remove_leading_sign in
Copy link
Collaborator

@cristianoc cristianoc Mar 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style/naming: perhaps:
let {positive, value} = parse_bigint i
where parse_bigint also removes the leading zeros, so there's no way one can forget to do that

let i = remove_leading_zeros i in
bigint sign i
| Bool b -> bool b
| Null -> nil
| Undefined -> undefined
Expand Down
2 changes: 1 addition & 1 deletion jscomp/core/js_exp_make.mli
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ val uint32 : ?comment:string -> int32 -> t

val small_int : int -> t

val bigint : ?comment:string -> string -> t
val bigint : ?comment:string -> bool -> string -> t

val float : ?comment:string -> string -> t

Expand Down
4 changes: 1 addition & 3 deletions jscomp/core/js_op.ml
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,11 @@ type 'a access = Getter | Setter
(* literal char *)
type float_lit = { f : string } [@@unboxed]

type bigint_lit = { i: string } [@@unboxed]

type number =
| Float of float_lit
| Int of { i : int32; c : int option }
| Uint of int32
| Bigint of bigint_lit
| Bigint of bool * string
Copy link
Collaborator

@cristianoc cristianoc Mar 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small style suggestion keep bigint_lit as { positive: bool; value: string }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, it seems not going to be unboxed, still okay?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The difference is going to be tiny in practice.


(* becareful when constant folding +/-,
since we treat it as js nativeint, bitwise operators:
Expand Down
2 changes: 1 addition & 1 deletion jscomp/core/lam.ml
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ let prim ~primitive:(prim : Lam_primitive.t) ~args loc : t =
(* FIXME: could raise? *)
Lift.bool
(Lam_compat.cmp_float cmp (float_of_string a) (float_of_string b))
| Pbigintcomp cmp, Const_bigint a, Const_bigint b -> default ()
| Pbigintcomp cmp, Const_bigint (_, a), Const_bigint (_, b) -> default ()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: here a and b are never used, I thought the compiler would give a warning

| Pintcomp ((Ceq | Cneq) as op), Const_pointer a, Const_pointer b ->
Lift.bool
(match op with
Expand Down
2 changes: 1 addition & 1 deletion jscomp/core/lam_analysis.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let not_zero_constant (x : Lam_constant.t) =
match x with
| Const_int { i } -> i <> 0l
| Const_int64 i -> i <> 0L
| Const_bigint i -> i <> "0"
| Const_bigint (_, i) -> i <> "0"
| _ -> false

let rec no_side_effects (lam : Lam.t) : bool =
Expand Down
2 changes: 1 addition & 1 deletion jscomp/core/lam_compile_const.ml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ and translate (x : Lam_constant.t) : J.expression =
(* E.float (Int64.to_string i) *)
Js_long.of_const i
(* https://github.com/google/closure-library/blob/master/closure%2Fgoog%2Fmath%2Flong.js *)
| Const_bigint i -> E.bigint i
| Const_bigint (sign, i) -> E.bigint sign i
| Const_float f -> E.float f (* TODO: preserve float *)
| Const_string { s; unicode = false } -> E.str s
| Const_string { s; unicode = true } -> E.str ~delim:DStarJ s
Expand Down
2 changes: 1 addition & 1 deletion jscomp/core/lam_constant_convert.ml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ let rec convert_constant (const : Lambda.structured_constant) : Lam_constant.t =
| Const_base (Const_float i) -> Const_float i
| Const_base (Const_int32 i) -> Const_int { i; comment = None }
| Const_base (Const_int64 i) -> Const_int64 i
| Const_base (Const_bigint i) -> Const_bigint i
| Const_base (Const_bigint (sign, i)) -> Const_bigint (sign, i)
| Const_pointer (0, Pt_constructor { name = "()"; const = 1; non_const = 0 })
->
Const_js_undefined {isUnit = true}
Expand Down
2 changes: 1 addition & 1 deletion jscomp/core/lam_print.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let rec struct_const ppf (cst : Lam_constant.t) =
| Const_string { s } -> fprintf ppf "%S" s
| Const_float f -> fprintf ppf "%s" f
| Const_int64 n -> fprintf ppf "%LiL" n
| Const_bigint i -> fprintf ppf "%sn" i
| Const_bigint (sign, i) -> fprintf ppf "%sn" (Bigint_utils.to_string sign i)
| Const_pointer name -> fprintf ppf "`%s" name
| Const_some n -> fprintf ppf "[some-c]%a" struct_const n
| Const_block (tag, _, []) -> fprintf ppf "[%i]" tag
Expand Down
4 changes: 3 additions & 1 deletion jscomp/frontend/external_ffi_types.ml
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ let inline_int64_primitive (i : int64) : string list =
[""; to_string (Ffi_inline_const (Const_int64 i))]

let inline_bigint_primitive (i : string) : string list =
[""; to_string (Ffi_inline_const (Const_bigint i))]
let sign, i = i |> Bigint_utils.remove_leading_sign in
let i = Bigint_utils.remove_leading_zeros i in
[""; to_string (Ffi_inline_const (Const_bigint (sign, i)))]

let inline_float_primitive (i : string) : string list =
[""; to_string (Ffi_inline_const (Const_float i))]
Expand Down
6 changes: 3 additions & 3 deletions jscomp/frontend/lam_constant.ml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type t =
| Const_string of {s: string; unicode: bool}
| Const_float of string
| Const_int64 of int64
| Const_bigint of string
| Const_bigint of bool * string
| Const_pointer of string
| Const_block of int * Lambda.tag_info * t list
| Const_float_array of string list
Expand Down Expand Up @@ -87,9 +87,9 @@ let rec eq_approx (x : t) (y : t) =
match y with
| Const_int64 iy -> ix = iy
| _ -> false)
| Const_bigint ix -> (
| Const_bigint (sx, ix) -> (
match y with
| Const_bigint iy -> ix = iy
| Const_bigint (sy, iy) -> sx = sy && ix = iy
| _ -> false)
| Const_pointer ix -> (
match y with
Expand Down
2 changes: 1 addition & 1 deletion jscomp/frontend/lam_constant.mli
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type t =
| Const_string of {s: string; unicode: bool}
| Const_float of string
| Const_int64 of int64
| Const_bigint of string
| Const_bigint of bool * string
| Const_pointer of string
| Const_block of int * Lambda.tag_info * t list
| Const_float_array of string list
Expand Down
2 changes: 1 addition & 1 deletion jscomp/ml/asttypes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type constant =
| Const_float of string
| Const_int32 of int32
| Const_int64 of int64
| Const_bigint of string
| Const_bigint of bool * string

type rec_flag = Nonrecursive | Recursive

Expand Down
32 changes: 21 additions & 11 deletions jscomp/ml/bigint_utils.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
let is_neg s = String.length s > 0 && s.[0] = '-'
let is_pos s = String.length s > 0 && s.[0] = '+'

let to_string sign s = (if sign then "" else "-") ^ s

let remove_leading_sign str : bool * string =
let len = String.length str in
if len = 0 then (false, str)
else
if is_neg str || is_pos str then (not (is_neg str), String.sub str 1 (len -1))
else (not (is_neg str), str)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: in this branch is_neg is impossible, so just (true, str)


(*
Removes leading zeros from the string only if the first non-zero character
encountered is a digit. Unlike int and float, bigint cannot be of_string, so
Expand Down Expand Up @@ -32,7 +44,7 @@ let remove_leading_zeros str =
let str = String.concat "" (String.split_on_char '_' str) in
(* Check if negative *)
let starts_with_minus = str <> "" && str.[0] = '-' in
let str = if starts_with_minus then String.sub str 1 (String.length str - 1) else str in
let str = if is_neg str || is_pos str then String.sub str 1 (String.length str - 1) else str in
let processed_str = aux str in
if starts_with_minus then "-" ^ processed_str else processed_str

Expand All @@ -42,7 +54,7 @@ let is_numeric s =
else
let is_digit c = (c >= '0' && c <= '9') || c = '_' in
let first_char = s.[0] in
if first_char <> '-' && not (is_digit first_char) then false
if first_char <> '-' && first_char <> '+' && not (is_digit first_char) then false
else
let rec check idx =
if idx >= len then true
Expand All @@ -53,18 +65,16 @@ let is_numeric s =
in
check 1

let compare s0 s1 =
(* check if negative *)
let is_neg s = String.length s > 0 && s.[0] = '-' in
match (is_neg s0, is_neg s1) with
| (true, false) -> -1 (* If only s0 is negative, it's smaller. *)
| (false, true) -> 1 (* If only s1 is negative, s0 is larger. *)
let compare (p0, s0) (p1, s1) =
match (p0, p1) with
| (false, true) -> -1 (* If only s1 is positive, s0 is smaller. *)
| (true, false) -> 1 (* If only s0 is positive, s0 is larger. *)
| _ ->
(* If both numbers are either negative or positive, compare their lengths. *)
let len0, len1 = (String.length s0, String.length s1) in
if len0 = len1 then
if is_neg s0 then String.compare s1 s0 else String.compare s0 s1 (* If lengths are equal, compare the strings directly. *)
if p0 then String.compare s0 s1 else String.compare s1 s0 (* If lengths are equal, compare the strings directly. *)
else if len0 > len1 then
if is_neg s0 then -1 else 1 (* A longer s0 means it's larger unless it's negative. *)
if p0 then 1 else -1 (* A longer s0 means it's larger unless it's negative. *)
else (* len0 < len1 *)
if is_neg s1 then 1 else -1 (* A longer s1 means s0 is smaller unless s1 is negative. *)
if p0 then -1 else 1 (* A longer s1 means s0 is smaller unless s1 is negative. *)
6 changes: 5 additions & 1 deletion jscomp/ml/bigint_utils.mli
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
val is_neg: string -> bool
val is_pos: string -> bool
val to_string: bool -> string -> string
val remove_leading_sign : string -> bool * string
val remove_leading_zeros : string -> string
val is_numeric : string -> bool
val compare : string -> string -> int
val compare : bool * string -> bool * string -> int
10 changes: 5 additions & 5 deletions jscomp/ml/parmatch.ml
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ let const_compare x y =
match x,y with
| Const_float f1, Const_float f2 ->
compare (float_of_string f1) (float_of_string f2)
| Const_bigint b1, Const_bigint b2 ->
Bigint_utils.compare b1 b2
| Const_bigint (s1, b1), Const_bigint (s2, b2) ->
Bigint_utils.compare (s1, b1) (s2, b2)
| Const_string (s1, _), Const_string (s2, _) ->
String.compare s1 s2
| _, _ -> compare x y
Expand Down Expand Up @@ -386,7 +386,7 @@ let pretty_const c = match c with
| Const_float f -> Printf.sprintf "%s" f
| Const_int32 i -> Printf.sprintf "%ldl" i
| Const_int64 i -> Printf.sprintf "%LdL" i
| Const_bigint i -> Printf.sprintf "%s" i
| Const_bigint (sign, i) -> Printf.sprintf "%s" (Bigint_utils.to_string sign i)

let rec pretty_val ppf v =
match v.pat_extra with
Expand Down Expand Up @@ -1106,8 +1106,8 @@ let build_other ext env : Typedtree.pattern = match env with
0L Int64.succ p env
| ({pat_desc=(Tpat_constant (Const_bigint _))} as p,_) :: _ ->
build_other_constant
(function Tpat_constant(Const_bigint i) -> String.length i | _ -> assert false)
(function i -> Tpat_constant(Const_bigint (String.make i '*')))
(function Tpat_constant(Const_bigint (sign, i)) -> String.length (Bigint_utils.to_string sign i) | _ -> assert false)
(function i -> Tpat_constant(Const_bigint (true, (String.make i '*'))))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what (String.make i '*') is doing here?
I would have guessed string_of_int i instead.
Not sure how to trigger this code path, perhaps with some example?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. I guess this function is used in pattern matching for gadt partially. But logically I think we can change (String.make i '*') to string_of_int i here for less space complexity.

0 succ p env
| ({pat_desc=(Tpat_constant (Const_string _))} as p,_) :: _ ->
build_other_constant
Expand Down
2 changes: 1 addition & 1 deletion jscomp/ml/printlambda.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let rec struct_const ppf = function
| Const_base(Const_float f) -> fprintf ppf "%s" f
| Const_base(Const_int32 n) -> fprintf ppf "%lil" n
| Const_base(Const_int64 n) -> fprintf ppf "%LiL" n
| Const_base(Const_bigint n) -> fprintf ppf "%sn" n
| Const_base(Const_bigint (sign, n)) -> fprintf ppf "%sn" (Bigint_utils.to_string sign n)
| Const_pointer (n,_) -> fprintf ppf "%ia" n
| Const_block(tag_info, []) ->
let tag = Lambda.tag_of_tag_info tag_info in
Expand Down
2 changes: 1 addition & 1 deletion jscomp/ml/printtyped.ml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ let fmt_constant f x =
| Const_float (s) -> fprintf f "Const_float %s" s;
| Const_int32 (i) -> fprintf f "Const_int32 %ld" i;
| Const_int64 (i) -> fprintf f "Const_int64 %Ld" i;
| Const_bigint (i) -> fprintf f "Const_bigint %s" i;
| Const_bigint (sign, i) -> fprintf f "Const_bigint %s" (Bigint_utils.to_string sign i);
;;

let fmt_mutable_flag f x =
Expand Down
10 changes: 3 additions & 7 deletions jscomp/ml/typecore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ type error =
| Empty_record_literal
| Uncurried_arity_mismatch of type_expr * int * int
| Field_not_optional of string * type_expr
| Invalid_decimal of string
exception Error of Location.t * Env.t * error
exception Error_forward of Location.error

Expand Down Expand Up @@ -261,9 +260,9 @@ let constant : Parsetree.constant -> (Asttypes.constant, error) result =
with Failure _ -> Error (Literal_overflow "int64")
end
| Pconst_integer (i,Some 'n') ->
if Bigint_utils.is_numeric i then
Ok (Const_bigint (Bigint_utils.remove_leading_zeros i))
else Error (Invalid_decimal i)
let sign, i = i |> Bigint_utils.remove_leading_sign in
let i = Bigint_utils.remove_leading_zeros i in
Ok (Const_bigint (sign, i))
| Pconst_integer (i,Some c) -> Error (Unknown_literal (i, c))
| Pconst_char c -> Ok (Const_char c)
| Pconst_string (s,d) -> Ok (Const_string (s,d))
Expand Down Expand Up @@ -4079,9 +4078,6 @@ let report_error env ppf = function
fprintf ppf
"Field @{<info>%s@} is not optional in type %a. Use without ?" name
type_expr typ
| Invalid_decimal s ->
fprintf ppf
"Invalid decimal literal '%sn'. Only decimal literal is allowed for bigint" s


let super_report_error_no_wrap_printing_env = report_error
Expand Down
1 change: 0 additions & 1 deletion jscomp/ml/typecore.mli
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ type error =
| Empty_record_literal
| Uncurried_arity_mismatch of type_expr * int * int
| Field_not_optional of string * type_expr
| Invalid_decimal of string
exception Error of Location.t * Env.t * error
exception Error_forward of Location.error

Expand Down
3 changes: 2 additions & 1 deletion jscomp/ml/untypeast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ let constant = function
| Const_int i -> Pconst_integer (string_of_int i, None)
| Const_int32 i -> Pconst_integer (Int32.to_string i, Some 'l')
| Const_int64 i -> Pconst_integer (Int64.to_string i, Some 'L')
| Const_bigint i -> Pconst_integer (i, Some 'n')
| Const_bigint (sign, i) ->
Pconst_integer (Bigint_utils.to_string sign i, Some 'n')
| Const_float f -> Pconst_float (f,None)

let attribute sub (s, p) = (map_loc sub s, p)
Expand Down
6 changes: 6 additions & 0 deletions jscomp/syntax/src/res_core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,12 @@ let parseConstant p =
let constant =
match p.Parser.token with
| Int {i; suffix} ->
(* Only decimal literal is allowed for bigint *)
if suffix = Some 'n' && not (Bigint_utils.is_numeric i) then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: perhaps is_numeric could be called is_valid?

Parser.err p
(Diagnostics.message
"Invalid decimal literal. Only decimal literal is allowed for \
Copy link
Collaborator

@cristianoc cristianoc Mar 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps "Invalid bigint literal. Only decimal...".

bigint.");
let intTxt = if isNegative then "-" ^ i else i in
Parsetree.Pconst_integer (intTxt, suffix)
| Float {f; suffix} ->
Expand Down
6 changes: 3 additions & 3 deletions jscomp/test/bigint_test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading