Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
- Avoid generating calls to Curry when adjusting arity of uncurried functions. https://github.com/rescript-lang/rescript-compiler/pull/6870
- Remove `@@uncurried.swap`, which was used for internal tests. https://github.com/rescript-lang/rescript-compiler/pull/6875
- Build the compiler libraries/tests in uncurried mode. https://github.com/rescript-lang/rescript-compiler/pull/6864
- Ignore `-uncurried` command-line flag. https://github.com/rescript-lang/rescript-compiler/pull/6885

#### :nail_care: Polish

Expand Down
8 changes: 2 additions & 6 deletions jscomp/bsc/rescript_compiler_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ let process_file sourcefile ?(kind ) ppf =
The {!Location.input_name} relies on that we write the binary ast
properly
*)
let uncurried = !Config.uncurried in
setup_outcome_printer ();
let kind =
match kind with
Expand Down Expand Up @@ -78,11 +77,9 @@ let process_file sourcefile ?(kind ) ppf =
| Unknown ->
Bsc_args.bad_arg ("don't know what to do with " ^ sourcefile)
in
Config.uncurried := uncurried;
res

let reprint_source_file sourcefile =
let uncurried = !Config.uncurried in
let kind = Ext_file_extensions.classify_input (Ext_filename.get_extension_maybe sourcefile) in
let sourcefile = set_abs_input_name sourcefile in
let res = match kind with
Expand Down Expand Up @@ -119,7 +116,6 @@ let reprint_source_file sourcefile =
print_endline ("Invalid input for reprinting ReScript source. Must be a ReScript file: " ^ sourcefile);
exit 2
in
Config.uncurried := uncurried;
res

let usage = "Usage: bsc <options> <files>\nOptions are:"
Expand Down Expand Up @@ -406,8 +402,8 @@ let buckle_script_flags : (string * Bsc_args.spec * string) array =

"-nopervasives", set Clflags.nopervasives,
"*internal*";
"-uncurried", unit_call (fun () -> Config.uncurried := Uncurried),
"*internal* Set jsx module";
"-uncurried", unit_call (fun () -> ()),
"*internal* deprecated";
"-v", unit_call print_version_string,
"Print compiler version and location of standard library and exit";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
2 │ let _ = string_of_float(34.)
3 │ let _ = string_of_float(34.)

deprecated: PervasivesU.string_of_float
deprecated: Pervasives.string_of_float
Please use Js.Float.toString instead, string_of_float generates unparseable floats


Expand All @@ -18,7 +18,7 @@
3 │ let _ = string_of_float(34.)
4 │

deprecated: PervasivesU.string_of_float
deprecated: Pervasives.string_of_float
Please use Js.Float.toString instead, string_of_float generates unparseable floats


Expand All @@ -30,5 +30,5 @@
3 │ let _ = string_of_float(34.)
4 │

deprecated: PervasivesU.string_of_float
deprecated: Pervasives.string_of_float
Please use Js.Float.toString instead, string_of_float generates unparseable floats
2 changes: 1 addition & 1 deletion jscomp/build_tests/super_errors/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const fixtures = fs
.filter(fileName => path.extname(fileName) === ".res");

// const runtime = path.join(__dirname, '..', '..', 'runtime')
const prefix = `${bsc} -w +A -uncurried`;
const prefix = `${bsc} -w +A`;

const updateTests = process.argv[2] === "update";

Expand Down
15 changes: 0 additions & 15 deletions jscomp/build_tests/uncurried_printer/input.js

This file was deleted.

6 changes: 0 additions & 6 deletions jscomp/build_tests/uncurried_printer/rescript.json

This file was deleted.

1 change: 0 additions & 1 deletion jscomp/build_tests/uncurried_printer/src/a.res

This file was deleted.

2 changes: 1 addition & 1 deletion jscomp/core/res_compmisc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ let initial_env ?(modulename) () =
let initial = Env.initial_safe_string in
let env =
if !Clflags.nopervasives then initial
else open_implicit_module (if !Config.uncurried = Uncurried then "PervasivesU" else "Pervasives") initial
else open_implicit_module "Pervasives" initial
in
List.fold_left
(fun env m -> open_implicit_module m env)
Expand Down
3 changes: 1 addition & 2 deletions jscomp/ext/config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ let bs_only = ref true
let unsafe_empty_array = ref false

type uncurried = Legacy | Uncurried
let uncurried = ref Legacy

and cmi_magic_number = "Caml1999I022"
let cmi_magic_number = "Caml1999I022"

and ast_impl_magic_number = "Caml1999M022"

Expand Down
1 change: 0 additions & 1 deletion jscomp/ext/config.mli
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ val cmt_magic_number : string
val print_config : out_channel -> unit

type uncurried = Legacy | Uncurried
val uncurried : uncurried ref
7 changes: 2 additions & 5 deletions jscomp/frontend/ast_attributes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,13 @@ let iter_process_bs_string_int_unwrap_uncurry (attrs : t) =
st := v)
else Bs_syntaxerr.err loc Conflict_attributes
in
Ext_list.iter attrs (fun (({txt; loc = _}, (payload : _)) as attr) ->
Ext_list.iter attrs (fun (({txt; loc = _}, _) as attr) ->
match txt with
| "string" -> assign `String attr
| "int" -> assign `Int attr
| "ignore" -> assign `Ignore attr
| "unwrap" -> assign `Unwrap attr
| "uncurry" ->
if !Config.uncurried = Uncurried then
Used_attributes.mark_used_attribute attr
else assign (`Uncurry (Ast_payload.is_single_int payload)) attr
| "uncurry" -> Used_attributes.mark_used_attribute attr
| _ -> ());
!st

Expand Down
2 changes: 0 additions & 2 deletions jscomp/frontend/ast_config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ let process_directives str =
match Ast_payload.is_single_string payload with
| Some (d, _) -> Js_config.directives := !Js_config.directives @ [d]
| None -> Bs_syntaxerr.err item.pstr_loc Expect_string_literal)
| Pstr_attribute ({txt = "uncurried"}, _) ->
Config.uncurried := Uncurried
| _ -> ())

let rec iter_on_bs_config_str (x : Parsetree.structure) =
Expand Down
13 changes: 4 additions & 9 deletions jscomp/frontend/ast_derive_projector.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ let init () =
(fun (tdcls : tdcls) _explict_nonrec ->
let handle_uncurried_accessor_tranform ~loc ~arity accessor =
(* Accessors with no params (arity of 0) are simply values and not functions *)
match Config.uncurried.contents with
| Uncurried when arity > 0 ->
Ast_uncurried.uncurried_fun ~loc ~arity accessor
| _ -> accessor
if arity > 0 then Ast_uncurried.uncurried_fun ~loc ~arity accessor
else accessor
in
let handle_tdcl tdcl =
let core_type =
Expand Down Expand Up @@ -121,11 +119,8 @@ let init () =
signature_gen =
(fun (tdcls : Parsetree.type_declaration list) _explict_nonrec ->
let handle_uncurried_type_tranform ~loc ~arity t =
match Config.uncurried.contents with
(* Accessors with no params (arity of 0) are simply values and not functions *)
| Uncurried when arity > 0 ->
Ast_uncurried.uncurried_type ~loc ~arity t
| _ -> t
if arity > 0 then Ast_uncurried.uncurried_type ~loc ~arity t
else t
in
let handle_tdcl tdcl =
let core_type =
Expand Down
9 changes: 0 additions & 9 deletions jscomp/jsoo/jsoo_playground_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,13 @@ module BundleConfig = struct
mutable filename: string option;
mutable warn_flags: string;
mutable open_modules: string list;

(* This one can't be mutated since we only provide
third-party packages that were compiled for uncurried
mode *)
uncurried: bool;
}

let make () = {
module_system=Ext_module_system.Commonjs;
filename=None;
warn_flags=Bsc_warnings.defaults_w;
open_modules=[];
uncurried=(!Config.uncurried = Uncurried);
}


Expand Down Expand Up @@ -201,8 +195,6 @@ end
(* One time setup for all relevant modules *)
let () =
Bs_conditional_initial.setup_env ();
(* From now on the default setting will be uncurried mode *)
Config.uncurried := Uncurried;
Clflags.binary_annotations := false;
Clflags.color := Some Always;
Lazy.force Res_outcome_printer.setup
Expand Down Expand Up @@ -646,7 +638,6 @@ module Export = struct
);
"warn_flags",
inject @@ (Js.string config.warn_flags);
"uncurried", inject @@ (Js.bool config.uncurried);
"open_modules", inject @@ (config.open_modules |> Array.of_list |> Js.array);
|]))
);
Expand Down
2 changes: 1 addition & 1 deletion jscomp/ml/ctype.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2329,7 +2329,7 @@ and unify3 env t1 t1' t2 t2' =
link_type t2' t1;
| (Tfield _, Tfield _) -> (* special case for GADTs *)
unify_fields env t1' t2'
| (Tconstr (Pident {name="function$"}, [t_fun; _], _), Tarrow _) when !Config.uncurried = Uncurried ->
| (Tconstr (Pident {name="function$"}, [t_fun; _], _), Tarrow _) ->
(* subtype: an uncurried function is cast to a curried one *)
unify2 env t_fun t2
| _ ->
Expand Down
1 change: 0 additions & 1 deletion jscomp/ml/typecore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3076,7 +3076,6 @@ and type_argument ?type_clash_context ?recarg env sarg ty_expected' ty_expected
texp
and is_automatic_curried_application env funct =
(* When a curried function is used with uncurried application, treat it as a curried application *)
!Config.uncurried = Uncurried &&
match (expand_head env funct.exp_type).desc with
| Tarrow _ -> true
| _ -> false
Expand Down
2 changes: 1 addition & 1 deletion jscomp/others/release.ninja
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

bsc_primitive_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -nostdlib -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A -uncurried
bsc_primitive_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -nostdlib -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A
bsc_flags = $bsc_primitive_flags -open Belt_internals

rule cc
Expand Down
4 changes: 2 additions & 2 deletions jscomp/runtime/release.ninja
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

bsc_no_open_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -nostdlib -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A -uncurried
bsc_no_open_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -nostdlib -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A
bsc_flags = $bsc_no_open_flags -open Bs_stdlib_mini

rule cc
Expand All @@ -10,7 +10,7 @@ rule cc_cmi
description = $in -> $out

o runtime/bs_stdlib_mini.cmi : cc runtime/bs_stdlib_mini.resi
bsc_flags = -nostdlib -nopervasives -uncurried
bsc_flags = -nostdlib -nopervasives
o runtime/js.cmj runtime/js.cmi : cc runtime/js.res
bsc_flags = $bsc_no_open_flags
o runtime/caml.cmj : cc_cmi runtime/caml.res | runtime/caml.cmi runtime/caml_int64_extern.cmj
Expand Down
18 changes: 9 additions & 9 deletions jscomp/stdlib-406/release.ninja
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

bsc_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -nostdlib -bs-cross-module-opt -make-runtime -w -9-3-106 -warn-error A -I others -uncurried
bsc_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -nostdlib -bs-cross-module-opt -make-runtime -w -9-3-106 -warn-error A -I others

rule cc
command = $bsc -bs-cmi -bs-cmj $bsc_flags -I stdlib-406 $in
Expand All @@ -9,15 +9,15 @@ rule cc_cmi
description = $in -> $out

o stdlib-406/pervasives.cmj : cc_cmi stdlib-406/pervasives.res | stdlib-406/pervasives.cmi $bsc others
bsc_flags = $bsc_flags -nopervasives -uncurried
bsc_flags = $bsc_flags -nopervasives
o stdlib-406/pervasives.cmi : cc stdlib-406/pervasives.resi | $bsc others
bsc_flags = $bsc_flags -nopervasives -uncurried
bsc_flags = $bsc_flags -nopervasives
o stdlib-406/pervasivesU.cmj : cc_cmi stdlib-406/pervasivesU.res | stdlib-406/pervasivesU.cmi $bsc others
bsc_flags = $bsc_flags -nopervasives -uncurried
bsc_flags = $bsc_flags -nopervasives
o stdlib-406/pervasivesU.cmi : cc stdlib-406/pervasivesU.resi | $bsc others
bsc_flags = $bsc_flags -nopervasives -uncurried
o stdlib-406/arg.cmj : cc_cmi stdlib-406/arg.res | stdlib-406/arg.cmi stdlib-406/array.cmj stdlib-406/buffer.cmj stdlib-406/list.cmj stdlib-406/string.cmj stdlib-406/sys.cmj $bsc others
o stdlib-406/arg.cmi : cc stdlib-406/arg.resi | stdlib-406/pervasives.cmj $bsc others
bsc_flags = $bsc_flags -nopervasives
o stdlib-406/arg.cmj : cc_cmi stdlib-406/arg.res | stdlib-406/arg.cmi stdlib-406/array.cmj stdlib-406/buffer.cmj stdlib-406/list.cmj stdlib-406/set.cmj stdlib-406/string.cmj stdlib-406/sys.cmj $bsc others
o stdlib-406/arg.cmi : cc stdlib-406/arg.resi | stdlib-406/pervasives.cmj stdlib-406/set.cmi stdlib-406/string.cmi $bsc others
o stdlib-406/array.cmj : cc_cmi stdlib-406/array.res | stdlib-406/array.cmi $bsc others
o stdlib-406/array.cmi : cc stdlib-406/array.resi | stdlib-406/pervasives.cmj $bsc others
o stdlib-406/arrayLabels.cmj : cc_cmi stdlib-406/arrayLabels.res | stdlib-406/arrayLabels.cmi $bsc others
Expand All @@ -43,7 +43,7 @@ o stdlib-406/digest.cmi : cc stdlib-406/digest.resi | stdlib-406/pervasives.cmj
o stdlib-406/filename.cmj : cc_cmi stdlib-406/filename.res | stdlib-406/buffer.cmj stdlib-406/filename.cmi stdlib-406/string.cmj stdlib-406/sys.cmj $bsc others
o stdlib-406/filename.cmi : cc stdlib-406/filename.resi | stdlib-406/pervasives.cmj $bsc others
o stdlib-406/genlex.cmj : cc_cmi stdlib-406/genlex.res | stdlib-406/bytes.cmj stdlib-406/char.cmj stdlib-406/genlex.cmi stdlib-406/hashtbl.cmj stdlib-406/list.cmj stdlib-406/stream.cmj stdlib-406/string.cmj $bsc others
o stdlib-406/genlex.cmi : cc stdlib-406/genlex.resi | stdlib-406/pervasives.cmj stdlib-406/stream.cmi $bsc others
o stdlib-406/genlex.cmi : cc stdlib-406/genlex.resi | stdlib-406/char.cmi stdlib-406/pervasives.cmj stdlib-406/stream.cmi stdlib-406/string.cmi $bsc others
o stdlib-406/hashtbl.cmj : cc_cmi stdlib-406/hashtbl.res | stdlib-406/array.cmj stdlib-406/hashtbl.cmi stdlib-406/lazy.cmj stdlib-406/random.cmj $bsc others
o stdlib-406/hashtbl.cmi : cc stdlib-406/hashtbl.resi | stdlib-406/pervasives.cmj $bsc others
o stdlib-406/hashtblLabels.cmi stdlib-406/hashtblLabels.cmj : cc stdlib-406/hashtblLabels.res | stdlib-406/hashtbl.cmj stdlib-406/pervasives.cmj $bsc others
Expand All @@ -70,7 +70,7 @@ o stdlib-406/parsing.cmj : cc_cmi stdlib-406/parsing.res | stdlib-406/array.cmj
o stdlib-406/parsing.cmi : cc stdlib-406/parsing.resi | stdlib-406/lexing.cmi stdlib-406/obj.cmi stdlib-406/pervasives.cmj $bsc others
o stdlib-406/queue.cmj : cc_cmi stdlib-406/queue.res | stdlib-406/queue.cmi $bsc others
o stdlib-406/queue.cmi : cc stdlib-406/queue.resi | stdlib-406/pervasives.cmj $bsc others
o stdlib-406/random.cmj : cc_cmi stdlib-406/random.res | stdlib-406/array.cmj stdlib-406/char.cmj stdlib-406/digest.cmj stdlib-406/int32.cmj stdlib-406/int64.cmj stdlib-406/random.cmi stdlib-406/string.cmj $bsc others
o stdlib-406/random.cmj : cc_cmi stdlib-406/random.res | stdlib-406/array.cmj stdlib-406/char.cmj stdlib-406/digest.cmj stdlib-406/int32.cmj stdlib-406/int64.cmj stdlib-406/random.cmi $bsc others
o stdlib-406/random.cmi : cc stdlib-406/random.resi | stdlib-406/int32.cmi stdlib-406/int64.cmi stdlib-406/pervasives.cmj $bsc others
o stdlib-406/set.cmj : cc_cmi stdlib-406/set.res | stdlib-406/list.cmj stdlib-406/set.cmi $bsc others
o stdlib-406/set.cmi : cc stdlib-406/set.resi | stdlib-406/pervasives.cmj $bsc others
Expand Down
8 changes: 3 additions & 5 deletions jscomp/syntax/src/jsx_v4.ml
Original file line number Diff line number Diff line change
Expand Up @@ -998,11 +998,9 @@ let map_binding ~config ~empty_loc ~pstr_loc ~file_name ~rec_flag binding =
else inner_expression)
in
let full_expression =
if !Config.uncurried = Uncurried then
full_expression
|> Ast_uncurried.uncurried_fun ~loc:full_expression.pexp_loc
~arity:(if has_forward_ref then 2 else 1)
else full_expression
full_expression
|> Ast_uncurried.uncurried_fun ~loc:full_expression.pexp_loc
~arity:(if has_forward_ref then 2 else 1)
in
let full_expression =
match full_module_name with
Expand Down
8 changes: 3 additions & 5 deletions jscomp/syntax/src/reactjs_jsx_v3.ml
Original file line number Diff line number Diff line change
Expand Up @@ -979,11 +979,9 @@ let jsx_mapper ~config =
inner_expression_with_ref
in
let full_expression =
if !Config.uncurried = Uncurried then
full_expression
|> Ast_uncurried.uncurried_fun ~loc:full_expression.pexp_loc
~arity:1
else full_expression
full_expression
|> Ast_uncurried.uncurried_fun ~loc:full_expression.pexp_loc
~arity:1
in
let full_expression =
match full_module_name with
Expand Down
Loading