Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
77a6290
Convert to snake case (#8456)
aspeddro Jun 3, 2026
eaa08ac
Improve non-function application error wording
JonoPrest Jun 1, 2026
ea4f1aa
Improve @return(*_to_opt) error message
JonoPrest Jun 1, 2026
924df9f
Improve @int variant @as payload error message
JonoPrest Jun 1, 2026
98e2ced
Improve conflicting-attributes error message
JonoPrest Jun 1, 2026
9941a5c
Render @ correctly in FFI attribute error messages
JonoPrest Jun 1, 2026
d4d6fe3
Improve @this simple-pattern error message
JonoPrest Jun 1, 2026
0d86cba
Tidy the "expected a string literal" error message
JonoPrest Jun 1, 2026
ada53da
Tidy the @as int/string/json literal error message
JonoPrest Jun 1, 2026
ddb077c
Tighten @this and @return wording for accuracy
JonoPrest Jun 2, 2026
0ae8105
Fix subject-verb agreement in type-params-not-supported error
JonoPrest Jun 2, 2026
25e71c3
Fix list grammar in @as variant annotation error
JonoPrest Jun 2, 2026
2834153
Use ReScript-style quoting for `let rec` in letrec errors
JonoPrest Jun 2, 2026
9863419
Drop OCaml-manual references from warning messages
JonoPrest Jun 2, 2026
9f649e2
Improve duplicate @as annotation error wording
JonoPrest Jun 2, 2026
2c756dc
Improve duplicate @deriving attribute error wording
JonoPrest Jun 2, 2026
5097a90
Improve unsupported @return directive error message
JonoPrest Jun 2, 2026
478c552
Make duplicate @as message context-neutral
JonoPrest Jun 2, 2026
93d326a
Report the real attribute name in misplaced @inline warning
JonoPrest Jun 2, 2026
ef95ef9
Use @-prefixed attribute names in attribute warnings
JonoPrest Jun 2, 2026
0bd1528
Name the conflicting attributes in the conflict error
JonoPrest Jun 2, 2026
df62d4c
Use 'switch' instead of OCaml ''match' expression' in no-value-clause…
JonoPrest Jun 2, 2026
efe7c2f
Say 'pattern' instead of OCaml 'matching' in multiply-bound-variable …
JonoPrest Jun 2, 2026
d15fc11
Clarify the fragile-pattern-in-toplevel error wording
JonoPrest Jun 2, 2026
ef9c443
State the rule in the invalid type-variable-name error
JonoPrest Jun 2, 2026
c001778
Fix pluralization and phrasing in type-arity-mismatch error
JonoPrest Jun 2, 2026
b7f5c45
Clarify packed-module / GADT-pattern / existential error messages
JonoPrest Jun 2, 2026
8670c1e
Backtick the type-constructor name in type-arity-mismatch error
JonoPrest Jun 2, 2026
c2cffb9
Add changelog entry for error/warning message improvements
JonoPrest Jun 2, 2026
fa243b1
Capitalize two lowercase error messages for consistency
JonoPrest Jun 2, 2026
76fd535
Cover new error-message branches flagged by codecov
JonoPrest Jun 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
- Refactor analysis to decouple I/O from core logic. https://github.com/rescript-lang/rescript/pull/8426
- Deprecate `Stdlib_Error` and `Stdlib_Exn` modules in favor of `JsError/JsExn`. https://github.com/rescript-lang/rescript/pull/8404
- Remove vendored `Json` library and use `yojson` and `lsp` library for analysis. https://github.com/rescript-lang/rescript/pull/8436
- Improve clarity of various error and warning messages. https://github.com/rescript-lang/rescript/pull/8460

#### :house: Internal

Expand All @@ -58,6 +59,7 @@
- Add a multi-file fixture harness (`super_errors_multi`) for cross-module errors and warnings. https://github.com/rescript-lang/rescript/pull/8433
- Catalog every named compiler error variant in `tests/ERROR_VARIANTS.md` and add fixtures for the remaining reachable ones. https://github.com/rescript-lang/rescript/pull/8446
- Remove dead and unreachable compiler error and warning variants; add fixtures for the ones found to be reachable. https://github.com/rescript-lang/rescript/pull/8459
- Convert OCaml codebase to snake case format. https://github.com/rescript-lang/rescript/pull/8456


# 13.0.0-alpha.4
Expand Down
119 changes: 65 additions & 54 deletions analysis/bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -93,116 +93,127 @@ Options:

let main () =
let args = Array.to_list Sys.argv in
let debugLevel, args =
let debug_level, args =
match args with
| _ :: "debug-dump" :: logLevel :: rest ->
( (match logLevel with
| _ :: "debug-dump" :: log_level :: rest ->
( (match log_level with
| "verbose" -> Debug.Verbose
| "regular" -> Regular
| _ -> Off),
"dummy" :: rest )
| args -> (Off, args)
in
Debug.debugLevel := debugLevel;
let debug = debugLevel <> Debug.Off in
let printHeaderInfo path line col =
Debug.debug_level := debug_level;
let debug = debug_level <> Debug.Off in
let print_header_info path line col =
if debug then
Printf.printf "Debug level: %s\n%s:%s-%s\n\n"
(match debugLevel with
(match debug_level with
| Debug.Verbose -> "verbose"
| Regular -> "regular"
| Off -> "off")
path line col
in
match args with
| [_; "cache-project"; rootPath] -> (
Cfg.readProjectConfigCache := false;
let uri = Uri.fromPath rootPath in
match Packages.getPackage ~uri with
| Some package -> Cache.cacheProject package
| [_; "cache-project"; root_path] -> (
Cfg.read_project_config_cache := false;
let uri = Uri.from_path root_path in
match Packages.get_package ~uri with
| Some package -> Cache.cache_project package
| None -> print_endline "\"ERR\"")
| [_; "cache-delete"; rootPath] -> (
Cfg.readProjectConfigCache := false;
let uri = Uri.fromPath rootPath in
match Packages.findRoot ~uri (Hashtbl.create 0) with
| Some (`Bs rootPath) -> (
match BuildSystem.getLibBs rootPath with
| [_; "cache-delete"; root_path] -> (
Cfg.read_project_config_cache := false;
let uri = Uri.from_path root_path in
match Packages.find_root ~uri (Hashtbl.create 0) with
| Some (`Bs root_path) -> (
match Build_system.get_lib_bs root_path with
| None -> print_endline "\"ERR\""
| Some libBs ->
Cache.deleteCache (Cache.targetFileFromLibBs libBs);
| Some lib_bs ->
Cache.delete_cache (Cache.target_file_from_lib_bs lib_bs);
print_endline "\"OK\"")
| _ -> print_endline "\"ERR: Did not find root \"")
| [_; "completion"; path; line; col; currentFile] ->
printHeaderInfo path line col;
| [_; "completion"; path; line; col; current_file] ->
print_header_info path line col;
Cli.completion ~debug ~path
~pos:(int_of_string line, int_of_string col)
~currentFile
| [_; "completionResolve"; path; modulePath] ->
Cli.completionResolve ~path ~modulePath
~current_file
| [_; "completionResolve"; path; module_path] ->
Cli.completion_resolve ~path ~module_path
| [_; "definition"; path; line; col] ->
Cli.definition ~path ~pos:(int_of_string line, int_of_string col) ~debug
| [_; "typeDefinition"; path; line; col] ->
Cli.typeDefinition ~path ~pos:(int_of_string line, int_of_string col) ~debug
| [_; "documentSymbol"; path] -> DocumentSymbol.command ~path
| [_; "hover"; path; line; col; currentFile; supportsMarkdownLinks] ->
Cli.type_definition ~path
~pos:(int_of_string line, int_of_string col)
~debug
| [_; "documentSymbol"; path] -> Document_symbol.command ~path
| [_; "hover"; path; line; col; current_file; supports_markdown_links] ->
Cli.hover ~path
~pos:(int_of_string line, int_of_string col)
~currentFile ~debug
~supportsMarkdownLinks:
(match supportsMarkdownLinks with
~current_file ~debug
~supports_markdown_links:
(match supports_markdown_links with
| "true" -> true
| _ -> false)
| [
_; "signatureHelp"; path; line; col; currentFile; allowForConstructorPayloads;
_;
"signatureHelp";
path;
line;
col;
current_file;
allow_for_constructor_payloads;
] ->
Cli.signatureHelp ~path
Cli.signature_help ~path
~pos:(int_of_string line, int_of_string col)
~currentFile ~debug
~allowForConstructorPayloads:
(match allowForConstructorPayloads with
~current_file ~debug
~allow_for_constructor_payloads:
(match allow_for_constructor_payloads with
| "true" -> true
| _ -> false)
| [_; "inlayHint"; path; line_start; line_end; maxLength] ->
| [_; "inlayHint"; path; line_start; line_end; max_length] ->
Cli.inlayhint ~path
~pos:(int_of_string line_start, int_of_string line_end)
~maxLength ~debug
| [_; "codeLens"; path] -> Cli.codeLens ~path ~debug
| [_; "codeAction"; path; startLine; startCol; endLine; endCol; currentFile]
->
Cli.codeAction ~path
~startPos:(int_of_string startLine, int_of_string startCol)
~endPos:(int_of_string endLine, int_of_string endCol)
~currentFile ~debug
~max_length ~debug
| [_; "codeLens"; path] -> Cli.code_lens ~path ~debug
| [
_; "codeAction"; path; start_line; start_col; end_line; end_col; current_file;
] ->
Cli.code_action ~path
~start_pos:(int_of_string start_line, int_of_string start_col)
~end_pos:(int_of_string end_line, int_of_string end_col)
~current_file ~debug
| [_; "codemod"; path; line; col; typ; hint] ->
let typ =
match typ with
| "add-missing-cases" -> Codemod.AddMissingCases
| _ -> raise (Failure "unsupported type")
in
let source = Files.readFile path |> Option.value ~default:"" in
let source = Files.read_file path |> Option.value ~default:"" in
`String
(Codemod.transform ~source
~pos:(int_of_string line, int_of_string col)
~debug ~typ ~hint)
|> Yojson.Safe.pretty_to_string ~std:true
|> print_endline
| [_; "diagnosticSyntax"; path] -> Cli.diagnosticSyntax ~path
| [_; "diagnosticSyntax"; path] -> Cli.diagnostic_syntax ~path
| [_; "references"; path; line; col] ->
Cli.references ~path ~pos:(int_of_string line, int_of_string col) ~debug
| [_; "prepareRename"; path; line; col] ->
Cli.prepareRename ~path ~pos:(int_of_string line, int_of_string col) ~debug
| [_; "rename"; path; line; col; newName] ->
Cli.prepare_rename ~path ~pos:(int_of_string line, int_of_string col) ~debug
| [_; "rename"; path; line; col; new_name] ->
Cli.rename ~path
~pos:(int_of_string line, int_of_string col)
~newName ~debug
| [_; "semanticTokens"; currentFile] -> Cli.semanticTokens ~path:currentFile
| [_; "createInterface"; path; cmiFile] ->
`String (CreateInterface.command ~path ~cmiFile)
~new_name ~debug
| [_; "semanticTokens"; current_file] ->
Cli.semantic_tokens ~path:current_file
| [_; "createInterface"; path; cmi_file] ->
`String (Create_interface.command ~path ~cmi_file)
|> Yojson.Safe.pretty_to_string ~std:true
|> print_endline
| [_; "format"; path] -> Cli.format ~path
| [_; "test"; path] -> Cli.test ~path
| [_; "cmt"; rescript_json; cmt_path] -> CmtViewer.dump rescript_json cmt_path
| [_; "cmt"; rescript_json; cmt_path] ->
Cmt_viewer.dump rescript_json cmt_path
| args when List.mem "-h" args || List.mem "--help" args -> prerr_endline help
| _ ->
prerr_endline help;
Expand Down
5 changes: 2 additions & 3 deletions analysis/reactive/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ build:

# Run all tests
test:
dune build test/ReactiveTest.exe
dune exec test/ReactiveTest.exe
dune build test/reactive_test.exe
dune exec test/reactive_test.exe

# Clean build artifacts
clean:
dune clean

2 changes: 1 addition & 1 deletion analysis/reactive/src/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(library
(name reactive)
(wrapped false)
(private_modules ReactiveFixpoint)
(private_modules reactive_fixpoint)
(libraries unix))
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ let source ~name () =

(** {1 FlatMap} *)

let flatMap ~name (src : ('k1, 'v1) t) ~f ?merge () : ('k2, 'v2) t =
let flat_map ~name (src : ('k1, 'v1) t) ~f ?merge () : ('k2, 'v2) t =
let my_level = src.level + 1 in
let merge_fn =
match merge with
Expand Down Expand Up @@ -1077,7 +1077,7 @@ let fixpoint ~name ~(init : ('k, unit) t) ~(edges : ('k, 'k list) t) () :
let my_level = max init.level edges.level + 1 in

(* Internal state *)
let state = ReactiveFixpoint.create () in
let state = Reactive_fixpoint.create () in
let subscribers = ref [] in
let my_stats = create_stats () in

Expand Down Expand Up @@ -1122,7 +1122,7 @@ let fixpoint ~name ~(init : ('k, unit) t) ~(edges : ('k, 'k list) t) () :
my_stats.removes_received + init_removes + edges_removes;

let output_entries =
ReactiveFixpoint.apply state ~init_entries ~edge_entries:edges_entries
Reactive_fixpoint.apply state ~init_entries ~edge_entries:edges_entries
in
emit_output output_entries
in
Expand All @@ -1145,14 +1145,15 @@ let fixpoint ~name ~(init : ('k, unit) t) ~(edges : ('k, 'k list) t) () :
Registry.mark_dirty name);

(* Initialize from existing data *)
ReactiveFixpoint.initialize state ~roots_iter:init.iter ~edges_iter:edges.iter;
Reactive_fixpoint.initialize state ~roots_iter:init.iter
~edges_iter:edges.iter;

{
name;
subscribe = (fun h -> subscribers := h :: !subscribers);
iter = (fun f -> ReactiveFixpoint.iter_current state f);
get = (fun k -> ReactiveFixpoint.get_current state k);
length = (fun () -> ReactiveFixpoint.current_length state);
iter = (fun f -> Reactive_fixpoint.iter_current state f);
get = (fun k -> Reactive_fixpoint.get_current state k);
length = (fun () -> Reactive_fixpoint.current_length state);
stats = my_stats;
level = my_level;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ val source : name:string -> unit -> ('k, 'v) t * (('k, 'v) delta -> unit)

(** {1 Combinators} *)

val flatMap :
val flat_map :
name:string ->
('k1, 'v1) t ->
f:('k1 -> 'v1 -> ('k2 * 'v2) list) ->
Expand Down
13 changes: 0 additions & 13 deletions analysis/reactive/test/ReactiveTest.ml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
(** Batch processing tests *)

open Reactive
open TestHelpers
open Test_helpers

let test_batch_flatmap () =
reset ();
Printf.printf "=== Test: batch flatmap ===\n";

let source, emit = source ~name:"source" () in
let derived =
flatMap ~name:"derived" source ~f:(fun k v -> [(k ^ "_derived", v * 2)]) ()
flat_map ~name:"derived" source ~f:(fun k v -> [(k ^ "_derived", v * 2)]) ()
in

(* Subscribe to track what comes out *)
Expand Down
22 changes: 11 additions & 11 deletions analysis/reactive/test/dune
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
(executable
(name ReactiveTest)
(name reactive_test)
(modules
ReactiveTest
TestHelpers
FlatMapTest
JoinTest
UnionTest
FixpointBasicTest
FixpointIncrementalTest
BatchTest
IntegrationTest
GlitchFreeTest)
reactive_test
test_helpers
flat_map_test
join_test
union_test
fixpoint_basic_test
fixpoint_incremental_test
batch_test
integration_test
glitch_free_test)
(libraries reactive))
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(** Incremental fixpoint update tests (add/remove base and edges) *)

open Reactive
open TestHelpers
open Test_helpers

let test_fixpoint_add_base () =
reset ();
Expand Down
Loading