Skip to content

Commit bbd84be

Browse files
authored
Merge branch 'master' into docstring-string
2 parents 7eca026 + a20fa10 commit bbd84be

File tree

152 files changed

+1312
-343
lines changed

Some content is hidden

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

152 files changed

+1312
-343
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* text=auto eol=lf
2+
13
*.ml linguist-language=OCaml
24
*.mli linguist-language=OCaml
35
*.res linguist-language=ReScript

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,6 @@ jobs:
511511
if: steps.diffcheck.outputs.clean == 'false'
512512
run: |
513513
npm ci
514-
npx rescript
515514
npm run build
516515
517516
- name: Commit and push

CHANGELOG.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,40 @@
1414

1515
#### :boom: Breaking Change
1616

17-
- Remove `String.getSymbol` from standard library.
18-
- Remove `String.getSymbolUnsafe` from standard library.
19-
- Remove `String.setSymbol` from standard library.
17+
- The legacy rescript cli can be called through rewatch via `rewatch legacy`. Arguments to rewatch need to be passed after the subcommand. Argument `--compiler-args` is now a subcommand `compiler-args`. https://github.com/rescript-lang/rescript/pull/7551
18+
- Remove `String.getSymbol` from standard library. https://github.com/rescript-lang/rescript/pull/7571
19+
- Remove `String.getSymbolUnsafe` from standard library. https://github.com/rescript-lang/rescript/pull/7571
20+
- Remove `String.setSymbol` from standard library. https://github.com/rescript-lang/rescript/pull/7571
21+
22+
#### :rocket: New Feature
23+
24+
- Add `OrThrow` aliases for `Belt` functions ending with `Exn`. https://github.com/rescript-lang/rescript/pull/7581, https://github.com/rescript-lang/rescript/pull/7590 The following aliases have been added:
25+
- `Belt.Array.getOrThrow`
26+
- `Belt.Array.setOrThrow`
27+
- `Belt.Map.getOrThrow`
28+
- `Belt.MutableMap.getOrThrow`
29+
- `Belt.Set.getOrThrow`
30+
- `Belt.MutableSet.getOrThrow`
31+
- `Belt.List.getOrThrow`
32+
- `Belt.List.tailOrThrow`
33+
- `Belt.List.headOrThrow`
34+
- `Belt.MutableQueue.peekOrThrow`
35+
- `Belt.MutableQueue.popOrThrow`
36+
- `Belt.Option.getOrThrow`
37+
- `Belt.Result.getOrThrow`
2038

2139
#### :bug: Bug fix
2240

2341
- Ignore inferred arity in functions inside `%raw` functions, leaving to `%ffi` the responsibility to check the arity since it gives an error in case of mismatch. https://github.com/rescript-lang/rescript/pull/7542
2442
- Pass the rewatch exit code through in wrapper script. https://github.com/rescript-lang/rescript/pull/7565
2543
- Prop punning when types don't match results in I/O error: _none_: No such file or directory. https://github.com/rescript-lang/rescript/pull/7533
2644
- Pass location to children prop in jsx ppx. https://github.com/rescript-lang/rescript/pull/7540
45+
- Fix crash when `bs-g` is used with untagged variants. https://github.com/rescript-lang/rescript/pull/7575
2746

2847
#### :nail_care: Polish
2948

3049
- Better error message for when trying to await something that is not a promise. https://github.com/rescript-lang/rescript/pull/7561
50+
- Better error messages for object field missing and object field type mismatches. https://github.com/rescript-lang/rescript/pull/7580
3151

3252
#### :house: Internal
3353

analysis/reanalyze/src/ExnLib.ml

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,38 @@
11
let raisesLibTable : (Name.t, Exceptions.t) Hashtbl.t =
22
let table = Hashtbl.create 15 in
33
let open Exn in
4-
let beltArray = [("getExn", [assertFailure]); ("setExn", [assertFailure])] in
4+
let beltArray =
5+
[
6+
("getExn", [assertFailure]);
7+
("getOrThrow", [assertFailure]);
8+
("setExn", [assertFailure]);
9+
("setOrThrow", [assertFailure]);
10+
]
11+
in
512
let beltList =
6-
[("getExn", [notFound]); ("headExn", [notFound]); ("tailExn", [notFound])]
13+
[
14+
("getExn", [notFound]);
15+
("getOrThrow", [notFound]);
16+
("headExn", [notFound]);
17+
("headOrThrow", [notFound]);
18+
("tailExn", [notFound]);
19+
("tailOrThrow", [notFound]);
20+
]
721
in
8-
let beltMap = [("getExn", [notFound])] in
22+
let beltMap = [("getExn", [notFound]); ("getOrThrow", [notFound])] in
923
let beltMutableMap = beltMap in
10-
let beltMutableQueue = [("peekExn", [notFound]); ("popExn", [notFound])] in
11-
let beltMutableSet = [("getExn", [notFound])] in
12-
let beltOption = [("getExn", [notFound])] in
13-
let beltResult = [("getExn", [notFound])] in
14-
let beltSet = [("getExn", [notFound])] in
24+
let beltMutableQueue =
25+
[
26+
("peekExn", [notFound]);
27+
("peekOrThrow", [notFound]);
28+
("popExn", [notFound]);
29+
("popOrThrow", [notFound]);
30+
]
31+
in
32+
let beltSet = [("getExn", [notFound]); ("getOrThrow", [notFound])] in
33+
let beltMutableSet = beltSet in
34+
let beltOption = [("getExn", [notFound]); ("getOrThrow", [notFound])] in
35+
let beltResult = [("getExn", [notFound]); ("getOrThrow", [notFound])] in
1536
let bsJson =
1637
(* bs-json *)
1738
[

biome.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"tests/tests/**/src/**",
6363
"tests/tools_tests/**/src/**",
6464
"analysis/examples/**/src/**",
65+
"rewatch/**",
6566
"lib/es6/**",
6667
"lib/js/**",
6768
"ninja/**",

cli/rewatch.js

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,37 @@ import { rewatch_exe, bsc_exe } from "./common/bins.js";
77

88
const args = process.argv.slice(2);
99

10+
const firstPositionalArgIndex = args.findIndex((arg) => !arg.startsWith("-"));
11+
1012
try {
11-
child_process.execFileSync(rewatch_exe, [...args, "--bsc-path", bsc_exe], {
12-
stdio: "inherit",
13-
});
13+
if (firstPositionalArgIndex !== -1) {
14+
const subcommand = args[firstPositionalArgIndex];
15+
const subcommandWithArgs = args.slice(firstPositionalArgIndex);
16+
17+
if (
18+
subcommand === "build" ||
19+
subcommand === "watch" ||
20+
subcommand === "clean" ||
21+
subcommand === "compiler-args"
22+
) {
23+
child_process.execFileSync(
24+
rewatch_exe,
25+
[...subcommandWithArgs, "--bsc-path", bsc_exe],
26+
{
27+
stdio: "inherit",
28+
}
29+
);
30+
} else {
31+
child_process.execFileSync(rewatch_exe, [...args], {
32+
stdio: "inherit",
33+
});
34+
}
35+
} else {
36+
// no subcommand means build subcommand
37+
child_process.execFileSync(rewatch_exe, [...args, "--bsc-path", bsc_exe], {
38+
stdio: "inherit",
39+
});
40+
}
1441
} catch (err) {
1542
if (err.status !== undefined) {
1643
process.exit(err.status); // Pass through the exit code

compiler/core/js_dump.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,8 @@ and expression_desc cxt ~(level : int) f x : cxt =
949949
| false, 1 -> Js_op.Lit Literals.tl
950950
| _ -> Js_op.Lit ("_" ^ string_of_int i)),
951951
e ))
952-
(if !Js_config.debug && not_is_cons then [(name_symbol, E.str p.name)]
952+
(if !Js_config.debug && (not untagged) && not_is_cons then
953+
[(name_symbol, E.str p.name)]
953954
else [])
954955
in
955956
if untagged || (not_is_cons = false && p.num_nonconst = 1) then tails

compiler/ml/printtyp.ml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,13 +1352,29 @@ let explanation unif t3 t4 ppf =
13521352
fprintf ppf "@,Self type cannot be unified with a closed object type"
13531353
| _, Tfield (lab, _, _, _) when lab = dummy_method ->
13541354
fprintf ppf "@,Self type cannot be unified with a closed object type"
1355-
| Tfield (l, _, _, {desc = Tnil}), Tfield (l', _, _, {desc = Tnil})
1355+
| Tfield (l, _, f1, {desc = Tnil}), Tfield (l', _, f2, {desc = Tnil})
13561356
when l = l' ->
1357-
fprintf ppf "@,Types for method %s are incompatible" l
1358-
| (Tnil | Tconstr _), Tfield (l, _, _, _) ->
1359-
fprintf ppf "@,@[The first object type has no field %s@]" l
1360-
| Tfield (l, _, _, _), (Tnil | Tconstr _) ->
1361-
fprintf ppf "@,@[The second object type has no field %s@]" l
1357+
fprintf ppf
1358+
"@,\
1359+
@,\
1360+
Types for field @{<info>\"%s\"@} are incompatible:@,\
1361+
Field @{<info>\"%s\"@} in the passed object has type @{<error>%a@}, but \
1362+
is expected to have type @{<info>%a@}."
1363+
l l type_expr f1 type_expr f2
1364+
| (Tnil | Tconstr _), Tfield (l, _, f1, _) ->
1365+
fprintf ppf
1366+
"@,\
1367+
@,\
1368+
@[The first object is expected to have a field @{<info>\"%s\"@} of type \
1369+
@{<info>%a@}, but it does not.@]"
1370+
l type_expr f1
1371+
| Tfield (l, _, f1, _), (Tnil | Tconstr _) ->
1372+
fprintf ppf
1373+
"@,\
1374+
@,\
1375+
@[The second object is expected to have a field @{<info>\"%s\"@} of \
1376+
type @{<info>%a@}, but it does not.@]"
1377+
l type_expr f1
13621378
| Tnil, Tconstr _ | Tconstr _, Tnil ->
13631379
fprintf ppf
13641380
"@,@[The %s object type has an abstract row, it cannot be closed@]"

lib/es6/Belt_Array.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function get(arr, i) {
1010

1111
}
1212

13-
function getExn(arr, i) {
13+
function getOrThrow(arr, i) {
1414
if (!(i >= 0 && i < arr.length)) {
1515
throw {
1616
RE_EXN_ID: "Assert_failure",
@@ -34,13 +34,13 @@ function set(arr, i, v) {
3434
}
3535
}
3636

37-
function setExn(arr, i, v) {
37+
function setOrThrow(arr, i, v) {
3838
if (!(i >= 0 && i < arr.length)) {
3939
throw {
4040
RE_EXN_ID: "Assert_failure",
4141
_1: [
4242
"Belt_Array.res",
43-
49,
43+
51,
4444
2
4545
],
4646
Error: new Error()
@@ -582,6 +582,10 @@ function init(n, f) {
582582
return v;
583583
}
584584

585+
let getExn = getOrThrow;
586+
587+
let setExn = setOrThrow;
588+
585589
let makeByU = makeBy;
586590

587591
let makeByAndShuffleU = makeByAndShuffle;
@@ -637,8 +641,10 @@ let initU = init;
637641
export {
638642
get,
639643
getExn,
644+
getOrThrow,
640645
set,
641646
setExn,
647+
setOrThrow,
642648
shuffleInPlace,
643649
shuffle,
644650
reverseInPlace,

lib/es6/Belt_List.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function head(x) {
1111

1212
}
1313

14-
function headExn(x) {
14+
function headOrThrow(x) {
1515
if (x !== 0) {
1616
return x.hd;
1717
}
@@ -28,7 +28,7 @@ function tail(x) {
2828

2929
}
3030

31-
function tailExn(x) {
31+
function tailOrThrow(x) {
3232
if (x !== 0) {
3333
return x.tl;
3434
}
@@ -67,7 +67,7 @@ function get(x, n) {
6767
}
6868
}
6969

70-
function getExn(x, n) {
70+
function getOrThrow(x, n) {
7171
if (n < 0) {
7272
throw {
7373
RE_EXN_ID: "Not_found",
@@ -1286,6 +1286,12 @@ function zip(l1, l2) {
12861286

12871287
let size = length;
12881288

1289+
let headExn = headOrThrow;
1290+
1291+
let tailExn = tailOrThrow;
1292+
1293+
let getExn = getOrThrow;
1294+
12891295
let makeByU = makeBy;
12901296

12911297
let mapU = map;
@@ -1357,11 +1363,14 @@ export {
13571363
size,
13581364
head,
13591365
headExn,
1366+
headOrThrow,
13601367
tail,
13611368
tailExn,
1369+
tailOrThrow,
13621370
add,
13631371
get,
13641372
getExn,
1373+
getOrThrow,
13651374
make,
13661375
makeByU,
13671376
makeBy,

0 commit comments

Comments
 (0)