Skip to content
Open
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
- Preserve trailing comments between the type and `=` in locally abstract value constraints (`let f: type a. t /* comment */ = value`). https://github.com/rescript-lang/rescript/pull/8575
- Enforce function arity in interface/module inclusion and type coercion. Previously a curried implementation (e.g. `int => int => int`) could satisfy an uncurried interface (`(int, int) => int`) or be coerced to it, which could miscompile calls made through the interface type. Such mismatches are now compile errors with an explanatory hint. https://github.com/rescript-lang/rescript/pull/8559
- Fix termination-analysis false positives for functions whose progress flows through un-annotated helpers: collecting the callees of a function binding was accidentally disabled in 2024 (the collection guard required a node shape that uncurried code never produces), so helpers calling `@progress` functions were no longer added to the function table. https://github.com/rescript-lang/rescript/pull/8568
- Fix default values of optional parameters being computed at the wrong time for curried functions: in `(~x=default, y) => (~z=default, w) => ...`, `x`'s default was only computed when the *inner* function was applied. Each default is now computed when its own parameter group is applied. https://github.com/rescript-lang/rescript/pull/8568
- Fix default values of optional parameters being computed at the wrong time for curried functions: in `(~x=default, y) => (~z=default, w) => ...`, `x`'s default was only computed when the _inner_ function was applied. Each default is now computed when its own parameter group is applied. https://github.com/rescript-lang/rescript/pull/8568
- Fix bare labeled arrow types (`~x: int => string`) getting no arity: they printed identically to their parenthesized form (`(~x: int) => string`) but did not unify with it. https://github.com/rescript-lang/rescript/pull/8563
- Fix losses of fidelity when code passes through an external PPX: the internal `@res.async` marker no longer leaks into the program, attributes on an arrow type or on an `await` expression are no longer dropped or relocated (previously this could crash the formatter), JSX elements keep their closing tag, and PPX-emitted OCaml-style `function` is desugared instead of crashing the compiler. https://github.com/rescript-lang/rescript/pull/8561
- Preserve multibyte characters when wrapping long source lines in compiler code frames. https://github.com/rescript-lang/rescript/pull/8520
Expand All @@ -60,6 +60,7 @@

#### :house: Internal

- Add genType and source map controls and output to the developer playground. https://github.com/rescript-lang/rescript/pull/8448
- Rework the object-type representation end to end: object rows are plain field chains carrying a per-field mutability state (no phantom setter members), object literals are typed directly and property access and assignment are first-class AST and Lambda nodes shared between the Lambda and JS pipelines, and dead class-system remnants (the field-presence lattice, the class-abbreviation memo on object types, method-send typing) are removed. https://github.com/rescript-lang/rescript/pull/8597
- Upgrade the development toolchain and primary CI builds to OCaml 5.5 while retaining OCaml 5.0 as the minimum supported version. https://github.com/rescript-lang/rescript/pull/8589
- Upgrade the vendored Flow parser from 0.267.0 to 0.320.0, the final release of the OCaml implementation. https://github.com/rescript-lang/rescript/pull/8588
Expand Down
16 changes: 12 additions & 4 deletions compiler/core/js_source_map.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type t = {
generated_dir: string;
source_root: string;
sources_content: bool;
provided_source_contents: (string, string) Hashtbl.t;
sources: (string, int) Hashtbl.t;
mutable source_list: source list;
mutable mappings: mapping list;
Expand Down Expand Up @@ -109,20 +110,27 @@ let relative_path ~from_dir ~to_file =
let parts = repeat ".." (List.length from_rest) @ to_rest in
if parts = [] then Filename.basename to_file else String.concat "/" parts

let make ~generated_file ~source_root ~sources_content =
let make ~source_contents ~generated_file ~source_root ~sources_content =
let provided_source_contents = Hashtbl.create (List.length source_contents) in
source_contents
|> List.iter (fun (filename, content) ->
Hashtbl.replace provided_source_contents (absolute_path filename) content);
{
generated_file = Filename.basename generated_file;
generated_dir = Filename.dirname generated_file;
source_root;
sources_content;
provided_source_contents;
sources = Hashtbl.create 4;
source_list = [];
mappings = [];
last_generated = None;
}

let load_content filename =
try Some (Ext_io.load_file filename) with _ -> None
let load_content builder filename =
match Hashtbl.find_opt builder.provided_source_contents filename with
| Some content -> Some content
| None -> ( try Some (Ext_io.load_file filename) with _ -> None)

let add_source builder filename =
let filename =
Expand All @@ -138,7 +146,7 @@ let add_source builder filename =
{
relative_path =
relative_path ~from_dir:builder.generated_dir ~to_file:filename;
content = load_content filename;
content = load_content builder filename;
}
in
let index = List.length builder.source_list in
Expand Down
6 changes: 5 additions & 1 deletion compiler/core/js_source_map.mli
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
type t

val make :
generated_file:string -> source_root:string -> sources_content:bool -> t
source_contents:(string * string) list ->
generated_file:string ->
source_root:string ->
sources_content:bool ->
t

val with_builder : t -> (unit -> 'a) -> 'a

Expand Down
2 changes: 1 addition & 1 deletion compiler/core/lam_compile_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ let remove_stale_source_map ?(remove_stale_map = true) target_file =
let dump_deps_program_with_source_map ?(remove_stale_map = true) ~target_file
~output_prefix module_system lambda_output chan =
let builder =
Js_source_map.make ~generated_file:target_file
Js_source_map.make ~source_contents:[] ~generated_file:target_file
~source_root:!Js_config.source_map_root
~sources_content:!Js_config.source_map_sources_content
in
Expand Down
2 changes: 1 addition & 1 deletion compiler/jsoo/dune
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
(= %{profile} browser))
(flags
(:standard -w +a-4-9-40-42-44-45))
(libraries core syntax ml js_of_ocaml))
(libraries core syntax ml gentype js_of_ocaml))
Loading
Loading