Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- Keep comments on labelled parameters with default values, and before `=?` in optional arrow-type arguments, when formatting. https://github.com/rescript-lang/rescript/pull/8690
- Fix invalid JavaScript that exported names left unbound when a module's toplevel always throws. https://github.com/rescript-lang/rescript/pull/8692
- Make module inclusion error messages independent of the length of the source file path. https://github.com/rescript-lang/rescript/pull/8691
- Fix the sign of `@inline` bigint constants printed in signatures and error messages, which showed `@inline(-12n)` for `@inline(12n)`. https://github.com/rescript-lang/rescript/pull/8732

#### :memo: Documentation

Expand Down
4 changes: 2 additions & 2 deletions compiler/frontend/ast_external_mk.ml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ let inline_bool b = inline_const (Const_bool b)
let inline_int i = inline_const (Const_int i)

let inline_bigint s =
let negative, digits = Bigint_utils.parse_bigint s in
inline_const (Const_bigint {negative; digits})
let positive, digits = Bigint_utils.parse_bigint s in
inline_const (Const_bigint {positive; digits})

let inline_float s = inline_const (Const_float s)
2 changes: 1 addition & 1 deletion compiler/ml/external_ffi_types.ml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type inline_const =
source spelling is not needed after FFI processing. *)
| Const_bool of bool
| Const_int of int32
| Const_bigint of {negative: bool; digits: string}
| Const_bigint of {positive: bool; digits: string}
| Const_float of string

type t =
Expand Down
2 changes: 1 addition & 1 deletion compiler/ml/external_ffi_types.mli
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type inline_const =
source spelling is not needed after FFI processing. *)
| Const_bool of bool
| Const_int of int32
| Const_bigint of {negative: bool; digits: string}
| Const_bigint of {positive: bool; digits: string}
| Const_float of string

type t = private
Expand Down
2 changes: 1 addition & 1 deletion compiler/ml/translcore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ let lambda_of_inline_const (c : External_ffi_types.inline_const) :
| Const_bool true -> Const_js_true
| Const_bool false -> Const_js_false
| Const_int i -> Const_int i
| Const_bigint {negative; digits} -> Const_bigint (negative, digits)
| Const_bigint {positive; digits} -> Const_bigint (positive, digits)
| Const_float f -> Const_float f

(* The argument of the dynamic-import primitive is a module reference,
Expand Down
4 changes: 2 additions & 2 deletions compiler/syntax/src/res_outcome_printer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,8 @@ let print_inline_const_doc (c : External_ffi_types.inline_const) =
| Const_string s -> print_string_literal_doc s
| Const_bool b -> Doc.text (if b then "true" else "false")
| Const_int i -> Doc.text (Int32.to_string i)
| Const_bigint {negative; digits} ->
Doc.text ((if negative then "-" else "") ^ digits ^ "n")
| Const_bigint {positive; digits} ->
Doc.text ((if positive then "" else "-") ^ digits ^ "n")
| Const_float f -> Doc.text f

let print_external_module_doc (emn : External_ffi_types.external_module_name) =
Expand Down
2 changes: 1 addition & 1 deletion tests/ERROR_VARIANTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ Wrapper symptoms attached to inclusion failures. Source: `type symptom` in [incl
| Variant | Status | Fixture | Notes |
|---|---|---|---|
| `Missing_field` | ✓ | `super_errors_multi/Iface_missing_value` | |
| `Value_descriptions` | ✓ | `super_errors_multi/Iface_value_descriptions`, `super_errors_multi/Iface_value_arity_mismatch`, `super_errors_multi/Smoke_interface_mismatch`, `super_errors_multi/Cross_external_spec_mismatch`, `super_errors_multi/Cross_external_payload_name`, `super_errors_multi/Cross_external_import_attrs`, `module_sig_value_arity_mismatch*.res`, `object_value_signature_set_mismatch.res` | Arity mismatches print a dedicated hint (implementation vs interface argument counts), including through aliases and nested function types. The object fixture pins that a value signature cannot drop `@set` from an object type (moregeneral requires equal field mutability). |
| `Value_descriptions` | ✓ | `super_errors_multi/Iface_value_descriptions`, `super_errors_multi/Iface_value_arity_mismatch`, `super_errors_multi/Smoke_interface_mismatch`, `super_errors_multi/Cross_external_spec_mismatch`, `super_errors_multi/Cross_external_payload_name`, `super_errors_multi/Cross_external_import_attrs`, `module_sig_value_arity_mismatch*.res`, `object_value_signature_set_mismatch.res`, `inline_bigint_signature_mismatch.res` | Arity mismatches print a dedicated hint (implementation vs interface argument counts), including through aliases and nested function types. The object fixture pins that a value signature cannot drop `@set` from an object type (moregeneral requires equal field mutability). The inline-bigint fixture pins the sign printed for `@inline(<bigint>)` values. |
| `Type_declarations` | ✓ | `super_errors_multi/Iface_type_decl_record`, `super_errors_multi/Iface_type_decl_variant`, `RecordInclusion.res`, `type_decl_function_arity_mismatch.res` | |
| `Extension_constructors` | ✓ | `super_errors_multi/Iface_extension_constructors` | |
| `Module_types` | ✓ | `super_errors_multi/Iface_module_types` | |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

We've found a bug for you!
/.../fixtures/inline_bigint_signature_mismatch.res:4:5-7:1

2 │ @inline(12n) let pos: bigint
3 │ @inline(-5n) let neg: bigint
4 │ } = {
5 │  let pos = 12n
6 │  let neg = -5n
7 │ }
8 │

Signature mismatch:
Modules do not match:
{
let pos: bigint
let neg: bigint
}
is not included in
{
@inline(12n) let pos: bigint
@inline(-5n) let neg: bigint
}
Values do not match:
let pos: bigint
is not included in
@inline(12n) let pos: bigint
/.../fixtures/inline_bigint_signature_mismatch.res:2:3-30:
Expected declaration
/.../fixtures/inline_bigint_signature_mismatch.res:5:7-9:
Actual declaration
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module M: {
@inline(12n) let pos: bigint
@inline(-5n) let neg: bigint
} = {
let pos = 12n
let neg = -5n
}
10 changes: 10 additions & 0 deletions tests/tests/src/inline_const.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ console.log([
3e-6
]);

function BigintConsts(X) {
return {
both: [
12n,
-5n
]
};
}

let x = true;

function N1(funarg) {
Expand All @@ -24,5 +33,6 @@ export {
N1,
h,
hh,
BigintConsts,
}
/* Not a pure module */
9 changes: 9 additions & 0 deletions tests/tests/src/inline_const.res
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,12 @@ let (a, b, c, d, e) = (f, f1, f2, f3, f4)
@inline let f6 = 1

let () = Console.log((xx, xx0))

module BigintConsts = (
X: {
@inline(12n) let pos: bigint
@inline(-5n) let neg: bigint
},
) => {
let both = (X.pos, X.neg)
}
9 changes: 9 additions & 0 deletions tests/tests/src/inline_const.resi
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,12 @@ let hh: string
@inline(true) let f5: bool

@inline(1) let f6: int

module BigintConsts: (
X: {
@inline(12n) let pos: bigint
@inline(-5n) let neg: bigint
},
) => {
let both: (bigint, bigint)
}
Loading