Skip to content

Commit c3ac921

Browse files
authored
Merge branch 'master' into jono/remove-sig-class
2 parents 4c4b308 + 28c3d4a commit c3ac921

145 files changed

Lines changed: 3721 additions & 671 deletions

File tree

Some content is hidden

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

.github/dependabot.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@ updates:
1010
- package-ecosystem: "github-actions"
1111
directory: "/"
1212
schedule:
13-
interval: "weekly"
13+
interval: "weekly"
14+
ignore:
15+
# Versions >1.4.3 interfere with caching done by our own CI script,
16+
# causing the dune binary not to be found anymore.
17+
- dependency-name: "awalsh128/cache-apt-pkgs-action"

.github/workflows/ci.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
git config --system core.longpaths true
9090
9191
- name: Checkout
92-
uses: actions/checkout@v6
92+
uses: actions/checkout@v7
9393

9494
- name: Use Node.js
9595
uses: actions/setup-node@v6
@@ -111,7 +111,7 @@ jobs:
111111

112112
- name: Restore rewatch build cache
113113
id: rewatch-build-cache
114-
uses: actions/cache@v5
114+
uses: actions/cache@v6
115115
with:
116116
path: rewatch/target
117117
key: rewatch-build-v3-${{ matrix.rust-target }}-${{ hashFiles('rewatch/src/**', 'rewatch/Cargo.lock') }}
@@ -165,7 +165,7 @@ jobs:
165165

166166
- name: Restore OPAM environment
167167
id: cache-opam-env
168-
uses: actions/cache/restore@v5
168+
uses: actions/cache/restore@v6
169169
with:
170170
path: |
171171
${{ runner.tool_cache }}/opam
@@ -201,7 +201,7 @@ jobs:
201201

202202
- name: Cache OPAM environment
203203
if: steps.cache-opam-env.outputs.cache-hit != 'true'
204-
uses: actions/cache/save@v5
204+
uses: actions/cache/save@v6
205205
with:
206206
path: |
207207
${{ runner.tool_cache }}/opam
@@ -259,7 +259,7 @@ jobs:
259259
- name: Restore compiler build state
260260
if: github.base_ref == 'master' || github.ref == 'refs/heads/master'
261261
id: compiler-build-state
262-
uses: actions/cache/restore@v5
262+
uses: actions/cache/restore@v6
263263
with:
264264
path: |
265265
C:\.cache\dune
@@ -284,7 +284,7 @@ jobs:
284284

285285
- name: Save compiler build state
286286
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
287-
uses: actions/cache/save@v5
287+
uses: actions/cache/save@v6
288288
with:
289289
path: |
290290
C:\.cache\dune
@@ -348,7 +348,7 @@ jobs:
348348
#
349349
# - name: Restore previous benchmark data
350350
# if: matrix.benchmarks
351-
# uses: actions/cache/restore@v5
351+
# uses: actions/cache/restore@v6
352352
# with:
353353
# path: ./tests/benchmark-cache
354354
# key: syntax-benchmark-v1
@@ -369,7 +369,7 @@ jobs:
369369

370370
# - name: Save benchmark data as new baseline
371371
# if: matrix.benchmarks && github.ref == 'refs/heads/master'
372-
# uses: actions/cache/save@v5
372+
# uses: actions/cache/save@v6
373373
# with:
374374
# path: ./tests/benchmark-cache
375375
# key: syntax-benchmark-v1
@@ -476,7 +476,7 @@ jobs:
476476
PLAYGROUND_BUNDLE_ID: master
477477
steps:
478478
- name: Checkout
479-
uses: actions/checkout@v6
479+
uses: actions/checkout@v7
480480

481481
- name: Use Node.js
482482
uses: actions/setup-node@v6
@@ -521,7 +521,7 @@ jobs:
521521
runs-on: ubuntu-24.04-arm
522522
steps:
523523
- name: Checkout
524-
uses: actions/checkout@v6
524+
uses: actions/checkout@v7
525525

526526
- name: Use Node.js
527527
uses: actions/setup-node@v6
@@ -554,7 +554,7 @@ jobs:
554554
runs-on: ubuntu-24.04-arm
555555
steps:
556556
- name: Checkout rescript-lang.org
557-
uses: actions/checkout@v6
557+
uses: actions/checkout@v7
558558
with:
559559
repository: rescript-lang/rescript-lang.org
560560
ssh-key: ${{ secrets.RESCRIPT_LANG_ORG_DEPLOY_KEY }}
@@ -601,7 +601,7 @@ jobs:
601601
runs-on: ubuntu-24.04-arm
602602
steps:
603603
- name: Checkout
604-
uses: actions/checkout@v6
604+
uses: actions/checkout@v7
605605
- name: Run make in dev container
606606
uses: devcontainers/ci@v0.3
607607
with:
@@ -623,7 +623,7 @@ jobs:
623623
runs-on: ${{ matrix.os }}
624624
steps:
625625
- name: Checkout
626-
uses: actions/checkout@v6
626+
uses: actions/checkout@v7
627627

628628
- name: Use Node.js
629629
uses: actions/setup-node@v6
@@ -683,7 +683,7 @@ jobs:
683683
node-version: 22
684684

685685
- name: Checkout
686-
uses: actions/checkout@v6
686+
uses: actions/checkout@v7
687687

688688
- name: Make test directory
689689
id: tmp-dir
@@ -727,7 +727,7 @@ jobs:
727727
runs-on: ${{ matrix.os }}
728728
steps:
729729
- name: Checkout
730-
uses: actions/checkout@v6
730+
uses: actions/checkout@v7
731731

732732
- name: Use Node.js
733733
uses: actions/setup-node@v6
@@ -757,7 +757,7 @@ jobs:
757757
runs-on: ubuntu-24.04-arm
758758
steps:
759759
- name: Checkout
760-
uses: actions/checkout@v6
760+
uses: actions/checkout@v7
761761

762762
- name: Use Node.js
763763
uses: actions/setup-node@v6

.github/workflows/coverage.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@ env:
1919
jobs:
2020
coverage:
2121
runs-on: ubuntu-24.04-arm
22+
permissions:
23+
actions: write # For build cache overwriting
24+
id-token: write # For CodeCov OIDC
2225
env:
2326
OS: ubuntu-24.04-arm
2427
OCAML_COMPILER: 5.3.0
2528
RUST_TARGET: aarch64-unknown-linux-gnu
2629
steps:
2730
- name: Checkout
28-
uses: actions/checkout@v6
31+
uses: actions/checkout@v7
2932

3033
- name: Use Node.js
3134
uses: actions/setup-node@v6
@@ -48,7 +51,7 @@ jobs:
4851
# and the cargo build when the rewatch sources haven't changed.
4952
- name: Restore rewatch build cache
5053
id: rewatch-build-cache
51-
uses: actions/cache@v5
54+
uses: actions/cache@v6
5255
with:
5356
path: rewatch/target
5457
key: rewatch-build-v3-${{ env.RUST_TARGET }}-${{ hashFiles('rewatch/src/**', 'rewatch/Cargo.lock') }}
@@ -86,7 +89,7 @@ jobs:
8689

8790
- name: Restore OPAM environment
8891
id: cache-opam-env
89-
uses: actions/cache/restore@v5
92+
uses: actions/cache/restore@v6
9093
with:
9194
path: |
9295
${{ runner.tool_cache }}/opam
@@ -124,7 +127,7 @@ jobs:
124127
# still get full restore from the latest master-saved cache.
125128
- name: Save OPAM environment
126129
if: steps.cache-opam-env.outputs.cache-hit != 'true' && github.event_name == 'push' && github.ref == 'refs/heads/master'
127-
uses: actions/cache/save@v5
130+
uses: actions/cache/save@v6
128131
with:
129132
path: |
130133
${{ runner.tool_cache }}/opam
@@ -165,7 +168,7 @@ jobs:
165168
- name: Restore coverage build state
166169
if: github.base_ref == 'master' || github.ref == 'refs/heads/master'
167170
id: coverage-build-state
168-
uses: actions/cache/restore@v5
171+
uses: actions/cache/restore@v6
169172
with:
170173
path: |
171174
~/.cache/dune
@@ -188,16 +191,16 @@ jobs:
188191

189192
- name: Save coverage build state
190193
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
191-
uses: actions/cache/save@v5
194+
uses: actions/cache/save@v6
192195
with:
193196
path: |
194197
~/.cache/dune
195198
_build
196199
key: ${{ steps.coverage-build-state-key.outputs.value }}
197200

198201
- name: Upload coverage to Codecov
199-
uses: codecov/codecov-action@v6
202+
uses: codecov/codecov-action@v7
200203
with:
201204
files: _coverage/coverage.json
202205
fail_ci_if_error: false
203-
token: ${{ secrets.CODECOV_TOKEN }}
206+
use_oidc: true

.ocamlformat-ignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
compiler/js_parser/**
21
**/*.cppo.ml
32
**/*.cppo.mli
4-
compiler/syntax/compiler-libs-406/*

.python-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

AGENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ tests/
126126
- Unit tests for utility functions
127127
- Always check JavaScript output quality
128128

129+
4. **Add a `CHANGELOG.md` entry** for any user-facing change (bug fix, feature, or breaking change). Put it under the matching section of the current `(Unreleased)` version and end the line with the PR link. See [CONTRIBUTING.md](CONTRIBUTING.md). PRs are expected to include one.
130+
129131
### Debugging Techniques
130132

131133
#### View Intermediate Representations

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
- Add a first-class `taggedTemplate<'param, 'output>` builtin type and the `TaggedTemplate` stdlib module (`TaggedTemplate.make`). Tagged-template tags are now tracked through the type system, so they emit real JS tagged-template syntax across module boundaries, when passed as first-class values, and when constructed at runtime by a factory (e.g. `postgres`). https://github.com/rescript-lang/rescript/pull/8461
2626
- Make mutation of private record mutable fields a configurable warning instead of a hard error. https://github.com/rescript-lang/rescript/pull/8366
27+
- Add support for pattern matching/destructuring of record rest. https://github.com/rescript-lang/rescript/pull/8317
2728

2829
#### :bug: Bug fix
2930

@@ -37,6 +38,8 @@
3738
- Fix formatting of trailing comments before `=` in let bindings. https://github.com/rescript-lang/rescript/pull/8444
3839
- Fix analysis namespace parsing after the Yojson migration. https://github.com/rescript-lang/rescript/pull/8454
3940
- Fix namespaced reference lookup in editor analysis. https://github.com/rescript-lang/rescript/pull/8455
41+
- Fix analysis segmentation fault for references after https://github.com/rescript-lang/rescript/pull/7887. https://github.com/rescript-lang/rescript/pull/8477
42+
- Fix build crash when the compiler emits output that is not valid UTF-8, such as a truncated multibyte character in a code frame. https://github.com/rescript-lang/rescript/pull/8482
4043

4144
#### :memo: Documentation
4245

@@ -68,6 +71,8 @@
6871
- Refactor analysis CLI helpers to use source input. https://github.com/rescript-lang/rescript/pull/8466
6972
- Include syntax, gentype, analysis, tools, and reanalyze tests in coverage reports. https://github.com/rescript-lang/rescript/pull/8467
7073
- Remove the unreachable `Longident.Lapply` constructor (OCaml's applicative-functor path syntax `F(X).t`, which ReScript's grammar cannot produce). https://github.com/rescript-lang/rescript/pull/8469
74+
- Refactor analysis for server side use. https://github.com/rescript-lang/rescript/pull/8478
75+
- Remove unused files. https://github.com/rescript-lang/rescript/pull/8481
7176
- Remove the dead `Sig_class`/`Sig_class_type` signature variants (OCaml class items, which ReScript cannot produce). https://github.com/rescript-lang/rescript/pull/8470
7277

7378
# 13.0.0-alpha.4

analysis/bin/main.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ let main () =
221221
| [_; "format"; path] -> Cli.format ~path
222222
| [_; "test"; path] -> Cli.test ~state ~path
223223
| [_; "cmt"; rescript_json; cmt_path] ->
224-
Cmt_viewer.dump ~state rescript_json cmt_path
224+
Cli.dump_cmt ~state ~rescript_json ~cmt_path
225225
| args when List.mem "-h" args || List.mem "--help" args -> prerr_endline help
226226
| _ ->
227227
prerr_endline help;

analysis/reanalyze/src/dead_value.ml

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,78 @@ let rec collect_expr ~config ~refs ~file_deps ~cross_file
230230
With this annotation we declare a new type for each branch to allow the
231231
function to be typed.
232232
*)
233-
let collect_pattern ~config ~refs :
233+
let type_path_candidates ~file ~(module_path : Module_path.t) path =
234+
let path = Dce_path.from_path_t path in
235+
let module_context =
236+
module_path.path @ [File_context.module_name_tagged file]
237+
in
238+
let add_unique paths path =
239+
if List.exists (fun existing -> existing = path) paths then paths
240+
else path :: paths
241+
in
242+
[path; path @ module_context]
243+
|> List.fold_left
244+
(fun paths path ->
245+
[
246+
path;
247+
Dce_path.module_to_implementation path;
248+
Dce_path.module_to_interface path;
249+
]
250+
|> List.fold_left add_unique paths)
251+
[]
252+
253+
let add_record_label_type_references ~config ~refs ~pos_from labels =
254+
labels
255+
|> List.iter (fun {Types.ld_loc = {loc_start = pos_to; loc_ghost}; _} ->
256+
if not loc_ghost then
257+
Dead_type.add_type_reference ~config ~refs ~pos_from ~pos_to)
258+
259+
let add_record_rest_type_references_from_path ~config ~decls ~refs ~file
260+
~module_path ~pos_from rest =
261+
if !Config.analyze_types then
262+
match (Ctype.repr rest.Typedtree.rest_type).desc with
263+
| Types.Tconstr (path, _, _) ->
264+
let type_paths = type_path_candidates ~file ~module_path path in
265+
decls |> Declarations.builder_to_list
266+
|> List.iter (fun (_, decl) ->
267+
match (decl.Decl.decl_kind, decl.path) with
268+
| RecordLabel, _label :: type_path
269+
when List.exists
270+
(fun candidate -> candidate = type_path)
271+
type_paths ->
272+
Dead_type.add_type_reference ~config ~refs ~pos_from
273+
~pos_to:decl.pos
274+
| _ -> ())
275+
| _ -> ()
276+
277+
let add_record_rest_type_references ~config ~decls ~refs ~file ~module_path
278+
~pos_from ~env rest =
279+
if !Config.analyze_types then
280+
match
281+
try Some (Ctype.extract_concrete_typedecl env rest.Typedtree.rest_type)
282+
with Not_found -> None
283+
with
284+
| Some (_, _, {Types.type_kind = Type_record (labels, _)}) ->
285+
add_record_label_type_references ~config ~refs ~pos_from labels
286+
| _ ->
287+
add_record_rest_type_references_from_path ~config ~decls ~refs ~file
288+
~module_path ~pos_from rest
289+
290+
let collect_pattern ~config ~decls ~refs ~file ~module_path :
234291
_ -> _ -> Typedtree.pattern -> Typedtree.pattern =
235292
fun super self pat ->
236293
let pos_from = pat.Typedtree.pat_loc.loc_start in
237294
(match pat.pat_desc with
238-
| Typedtree.Tpat_record (cases, _clodsedFlag) ->
295+
| Typedtree.Tpat_record (cases, _clodsedFlag, rest) -> (
239296
cases
240297
|> List.iter (fun (_loc, {Types.lbl_loc = {loc_start = pos_to}}, _pat, _) ->
241298
if !Config.analyze_types then
242-
Dead_type.add_type_reference ~config ~refs ~pos_from ~pos_to)
299+
Dead_type.add_type_reference ~config ~refs ~pos_from ~pos_to);
300+
match rest with
301+
| None -> ()
302+
| Some rest ->
303+
add_record_rest_type_references ~config ~decls ~refs ~file ~module_path
304+
~pos_from:rest.rest_name.loc.loc_start ~env:pat.pat_env rest)
243305
| _ -> ());
244306
super.Tast_mapper.pat self pat
245307

@@ -331,7 +393,11 @@ let traverse_structure ~config ~decls ~refs ~file_deps ~cross_file ~file
331393
e
332394
|> collect_expr ~config ~refs ~file_deps ~cross_file ~last_binding
333395
super mapper);
334-
pat = (fun _self p -> p |> collect_pattern ~config ~refs super mapper);
396+
pat =
397+
(fun _self p ->
398+
p
399+
|> collect_pattern ~config ~decls ~refs ~file ~module_path super
400+
mapper);
335401
structure_item =
336402
(fun _self (structure_item : Typedtree.structure_item) ->
337403
let modulePath_for_item_opt =

0 commit comments

Comments
 (0)