Skip to content

Commit 818b6fd

Browse files
committed
Fix format.sh to properly exit on errors and use opam exec
- Add 'set -e' to exit immediately on errors - Use 'opam exec --' to match checkformat.sh behavior - Now make format will fail visibly instead of silently continuing when formatting fails
1 parent ed06896 commit 818b6fd

File tree

6 files changed

+26
-17
lines changed

6 files changed

+26
-17
lines changed

analysis.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license: "LGPL-3.0-or-later"
77
homepage: "https://github.com/rescript-lang/rescript-compiler"
88
bug-reports: "https://github.com/rescript-lang/rescript-compiler/issues"
99
depends: [
10-
"ocaml" {>= "4.14"}
10+
"ocaml" {>= "5.0.1"}
1111
"cppo" {= "1.8.0"}
1212
"dune" {>= "3.17"}
1313
"odoc" {with-doc}

analysis/reanalyze/src/Reanalyze.ml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ let runAnalysis ~dce_config ~cmtRoot =
245245
in
246246
(* Analysis phase: merge data and solve *)
247247
let analysis_result =
248-
if dce_config.DceConfig.run.dce then (
248+
if dce_config.DceConfig.run.dce then
249249
(* Merging phase: combine all builders -> immutable data *)
250250
let annotations, decls, cross_file, refs, file_deps =
251251
Timing.time_phase `Merging (fun () ->
@@ -256,7 +256,8 @@ let runAnalysis ~dce_config ~cmtRoot =
256256
in
257257
let decls =
258258
Declarations.merge_all
259-
(dce_data_list |> List.map (fun fd -> fd.DceFileProcessing.decls))
259+
(dce_data_list
260+
|> List.map (fun fd -> fd.DceFileProcessing.decls))
260261
in
261262
let cross_file =
262263
CrossFileItems.merge_all
@@ -271,11 +272,14 @@ let runAnalysis ~dce_config ~cmtRoot =
271272
References.merge_into_builder ~from:fd.DceFileProcessing.refs
272273
~into:refs_builder;
273274
FileDeps.merge_into_builder
274-
~from:fd.DceFileProcessing.file_deps ~into:file_deps_builder);
275+
~from:fd.DceFileProcessing.file_deps
276+
~into:file_deps_builder);
275277
(* Compute type-label dependencies after merge *)
276278
DeadType.process_type_label_dependencies ~config:dce_config ~decls
277279
~refs:refs_builder;
278-
let find_exception = DeadException.find_exception_from_decls decls in
280+
let find_exception =
281+
DeadException.find_exception_from_decls decls
282+
in
279283
(* Process cross-file exception refs *)
280284
CrossFileItems.process_exception_refs cross_file ~refs:refs_builder
281285
~file_deps:file_deps_builder ~find_exception ~config:dce_config;
@@ -300,7 +304,8 @@ let runAnalysis ~dce_config ~cmtRoot =
300304
| None -> true
301305
in
302306
let optional_args_state =
303-
CrossFileItems.compute_optional_args_state cross_file ~decls ~is_live
307+
CrossFileItems.compute_optional_args_state cross_file ~decls
308+
~is_live
304309
in
305310
(* Collect optional args issues only for live declarations *)
306311
let optional_args_issues =
@@ -316,7 +321,8 @@ let runAnalysis ~dce_config ~cmtRoot =
316321
decls []
317322
|> List.rev
318323
in
319-
Some (AnalysisResult.add_issues analysis_result_core optional_args_issues)))
324+
Some
325+
(AnalysisResult.add_issues analysis_result_core optional_args_issues))
320326
else None
321327
in
322328
(* Reporting phase *)

analysis/reanalyze/src/Timing.ml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ type phase_times = {
1313
mutable reporting: float;
1414
}
1515

16-
let times = {
17-
file_loading = 0.0;
18-
result_collection = 0.0;
19-
merging = 0.0;
20-
solving = 0.0;
21-
reporting = 0.0;
22-
}
16+
let times =
17+
{
18+
file_loading = 0.0;
19+
result_collection = 0.0;
20+
merging = 0.0;
21+
solving = 0.0;
22+
reporting = 0.0;
23+
}
2324

2425
(* Mutex to protect timing updates from concurrent domains *)
2526
let timing_mutex = Mutex.create ()

rescript.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ build: [
2121
]
2222
]
2323
depends: [
24-
"ocaml" {>= "4.14"}
24+
"ocaml" {>= "5.0.1"}
2525
"cppo" {= "1.8.0"}
2626
"dune" {>= "3.17"}
2727
"flow_parser" {= "0.267.0"}

scripts/format.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#!/bin/bash
22

3+
set -e
4+
35
shopt -s extglob
46

57
echo Formatting OCaml code...
6-
dune build @fmt --auto-promote
8+
opam exec -- dune build @fmt --auto-promote
79

810
echo Formatting ReScript code...
911
files=$(find packages tests -type f \( -name "*.res" -o -name "*.resi" \) ! -name "syntaxErrors*" ! -name "generated_mocha_test.res" ! -path "tests/syntax_tests*" ! -path "tests/analysis_tests/tests*" ! -path "*/node_modules/*")

tools.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license: "LGPL-3.0-or-later"
77
homepage: "https://github.com/rescript-lang/rescript-compiler"
88
bug-reports: "https://github.com/rescript-lang/rescript-compiler/issues"
99
depends: [
10-
"ocaml" {>= "4.14"}
10+
"ocaml" {>= "5.0.1"}
1111
"cmarkit" {>= "0.3.0"}
1212
"cppo" {= "1.8.0"}
1313
"analysis"

0 commit comments

Comments
 (0)