Skip to content

Commit 786b115

Browse files
committed
Audit what files are compiled in curried mode.
Add a `-curried` option, and give an error whenever neither `-curried` not `-uncurried` are used. Then change the build and test files to always specify curried/uncurried.
1 parent f04aa3f commit 786b115

File tree

7 files changed

+23
-15
lines changed

7 files changed

+23
-15
lines changed

jscomp/bsc/rescript_compiler_main.ml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ let setup_runtime_path path =
3434
Bs_version.package_name := std);
3535
Js_config.customize_runtime := Some path
3636

37+
let curry_specified = ref false
38+
3739

3840
let process_file sourcefile ?(kind ) ppf =
3941
(* This is a better default then "", it will be changed later
@@ -46,6 +48,11 @@ let process_file sourcefile ?(kind ) ppf =
4648
match kind with
4749
| None -> Ext_file_extensions.classify_input (Ext_filename.get_extension_maybe sourcefile)
4850
| Some kind -> kind in
51+
(if !curry_specified = false && !Clflags.dump_source = false && !Js_config.syntax_only = false && List.mem kind [Res; Resi] then
52+
let _ = Printf.eprintf "XXX curry not specified %s\n%!" sourcefile in
53+
let _ = assert false in
54+
()
55+
);
4956
let res = match kind with
5057
| Res ->
5158
let sourcefile = set_abs_input_name sourcefile in
@@ -406,8 +413,10 @@ let buckle_script_flags : (string * Bsc_args.spec * string) array =
406413

407414
"-nopervasives", set Clflags.nopervasives,
408415
"*internal*";
409-
"-uncurried", unit_call (fun () -> Config.uncurried := Uncurried),
410-
"*internal* Set jsx module";
416+
"-uncurried", unit_call (fun () -> curry_specified := true; Config.uncurried := Uncurried),
417+
"*internal*";
418+
"-curried", unit_call (fun () -> curry_specified := true; Config.uncurried := Legacy),
419+
"*internal*";
411420
"-v", unit_call print_version_string,
412421
"Print compiler version and location of standard library and exit";
413422

jscomp/build_tests/super_errors/input.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const fixtures = fs
1111
.filter(fileName => path.extname(fileName) === ".res");
1212

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

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

jscomp/others/release.ninja

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
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
2+
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 -curried
33
bsc_flags = $bsc_primitive_flags -open Belt_internals
44

55
rule cc
@@ -53,7 +53,6 @@ o others/js_result.cmi : cc others/js_result.resi | others/belt_internals.cmi ot
5353
o others/js_set.cmi others/js_set.cmj : cc others/js_set.res | others/belt_internals.cmi others/js.cmi $bsc
5454
o others/js_string.cmi others/js_string.cmj : cc others/js_string.res | others/belt_internals.cmi others/js.cmi others/js_array2.cmj others/js_re.cmj $bsc
5555
o others/js_string2.cmi others/js_string2.cmj : cc others/js_string2.res | others/belt_internals.cmi others/js.cmi others/js_array2.cmj others/js_re.cmj $bsc
56-
o others/js_typed_array.cmi others/js_typed_array.cmj : cc others/js_typed_array.res | others/belt_internals.cmi others/js.cmi others/js_typed_array2.cmj $bsc
5756
o others/js_typed_array2.cmi others/js_typed_array2.cmj : cc others/js_typed_array2.res | others/belt_internals.cmi others/js.cmi $bsc
5857
o others/js_types.cmj : cc_cmi others/js_types.res | others/belt_internals.cmi others/js.cmi others/js_null.cmj others/js_types.cmi $bsc
5958
o others/js_types.cmi : cc others/js_types.resi | others/belt_internals.cmi others/js.cmi $bsc
@@ -72,7 +71,7 @@ o others/jsxEventU.cmi others/jsxEventU.cmj : cc others/jsxEventU.res | others/b
7271
o others/jsxPPXReactSupportC.cmi others/jsxPPXReactSupportC.cmj : cc others/jsxPPXReactSupportC.res | others/belt_internals.cmi others/js.cmi others/jsxC.cmj $bsc
7372
o others/jsxPPXReactSupportU.cmi others/jsxPPXReactSupportU.cmj : cc others/jsxPPXReactSupportU.res | others/belt_internals.cmi others/js.cmi others/jsxU.cmj $bsc
7473
o others/jsxU.cmi others/jsxU.cmj : cc others/jsxU.res | others/belt_internals.cmi others/js.cmi $bsc
75-
o js_pkg : phony others/js_OO.cmi others/js_OO.cmj others/js_array.cmi others/js_array.cmj others/js_array2.cmi others/js_array2.cmj others/js_bigint.cmi others/js_bigint.cmj others/js_blob.cmi others/js_blob.cmj others/js_cast.cmi others/js_cast.cmj others/js_console.cmi others/js_console.cmj others/js_date.cmi others/js_date.cmj others/js_dict.cmi others/js_dict.cmj others/js_exn.cmi others/js_exn.cmj others/js_file.cmi others/js_file.cmj others/js_float.cmi others/js_float.cmj others/js_global.cmi others/js_global.cmj others/js_int.cmi others/js_int.cmj others/js_json.cmi others/js_json.cmj others/js_list.cmi others/js_list.cmj others/js_map.cmi others/js_map.cmj others/js_math.cmi others/js_math.cmj others/js_null.cmi others/js_null.cmj others/js_null_undefined.cmi others/js_null_undefined.cmj others/js_obj.cmi others/js_obj.cmj others/js_option.cmi others/js_option.cmj others/js_promise.cmi others/js_promise.cmj others/js_promise2.cmi others/js_promise2.cmj others/js_re.cmi others/js_re.cmj others/js_result.cmi others/js_result.cmj others/js_set.cmi others/js_set.cmj others/js_string.cmi others/js_string.cmj others/js_string2.cmi others/js_string2.cmj others/js_typed_array.cmi others/js_typed_array.cmj others/js_typed_array2.cmi others/js_typed_array2.cmj others/js_types.cmi others/js_types.cmj others/js_undefined.cmi others/js_undefined.cmj others/js_vector.cmi others/js_vector.cmj others/js_weakmap.cmi others/js_weakmap.cmj others/js_weakset.cmi others/js_weakset.cmj others/jsxC.cmi others/jsxC.cmj others/jsxDOMC.cmi others/jsxDOMC.cmj others/jsxDOMStyle.cmi others/jsxDOMStyle.cmj others/jsxDOMU.cmi others/jsxDOMU.cmj others/jsxEventC.cmi others/jsxEventC.cmj others/jsxEventU.cmi others/jsxEventU.cmj others/jsxPPXReactSupportC.cmi others/jsxPPXReactSupportC.cmj others/jsxPPXReactSupportU.cmi others/jsxPPXReactSupportU.cmj others/jsxU.cmi others/jsxU.cmj
74+
o js_pkg : phony others/js_OO.cmi others/js_OO.cmj others/js_array.cmi others/js_array.cmj others/js_array2.cmi others/js_array2.cmj others/js_bigint.cmi others/js_bigint.cmj others/js_blob.cmi others/js_blob.cmj others/js_cast.cmi others/js_cast.cmj others/js_console.cmi others/js_console.cmj others/js_date.cmi others/js_date.cmj others/js_dict.cmi others/js_dict.cmj others/js_exn.cmi others/js_exn.cmj others/js_file.cmi others/js_file.cmj others/js_float.cmi others/js_float.cmj others/js_global.cmi others/js_global.cmj others/js_int.cmi others/js_int.cmj others/js_json.cmi others/js_json.cmj others/js_list.cmi others/js_list.cmj others/js_map.cmi others/js_map.cmj others/js_math.cmi others/js_math.cmj others/js_null.cmi others/js_null.cmj others/js_null_undefined.cmi others/js_null_undefined.cmj others/js_obj.cmi others/js_obj.cmj others/js_option.cmi others/js_option.cmj others/js_promise.cmi others/js_promise.cmj others/js_promise2.cmi others/js_promise2.cmj others/js_re.cmi others/js_re.cmj others/js_result.cmi others/js_result.cmj others/js_set.cmi others/js_set.cmj others/js_string.cmi others/js_string.cmj others/js_string2.cmi others/js_string2.cmj others/js_typed_array2.cmi others/js_typed_array2.cmj others/js_types.cmi others/js_types.cmj others/js_undefined.cmi others/js_undefined.cmj others/js_vector.cmi others/js_vector.cmj others/js_weakmap.cmi others/js_weakmap.cmj others/js_weakset.cmi others/js_weakset.cmj others/jsxC.cmi others/jsxC.cmj others/jsxDOMC.cmi others/jsxDOMC.cmj others/jsxDOMStyle.cmi others/jsxDOMStyle.cmj others/jsxDOMU.cmi others/jsxDOMU.cmj others/jsxEventC.cmi others/jsxEventC.cmj others/jsxEventU.cmi others/jsxEventU.cmj others/jsxPPXReactSupportC.cmi others/jsxPPXReactSupportC.cmj others/jsxPPXReactSupportU.cmi others/jsxPPXReactSupportU.cmj others/jsxU.cmi others/jsxU.cmj
7675
o others/belt_Array.cmj : cc_cmi others/belt_Array.res | others/belt.cmi others/belt_Array.cmi others/belt_internals.cmi others/js.cmi $bsc js_pkg
7776
o others/belt_Array.cmi : cc others/belt_Array.resi | others/belt_internals.cmi others/js.cmi $bsc
7877
o others/belt_Float.cmj : cc_cmi others/belt_Float.res | others/belt.cmi others/belt_Float.cmi others/belt_internals.cmi others/js.cmi $bsc js_pkg

jscomp/runtime/release.ninja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
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
2+
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 -curried
33
bsc_flags = $bsc_no_open_flags -open Bs_stdlib_mini
44

55
rule cc
@@ -10,7 +10,7 @@ rule cc_cmi
1010
description = $in -> $out
1111

1212
o runtime/bs_stdlib_mini.cmi : cc runtime/bs_stdlib_mini.resi
13-
bsc_flags = -nostdlib -nopervasives
13+
bsc_flags = -nostdlib -nopervasives -curried
1414
o runtime/js.cmj runtime/js.cmi : cc runtime/js.res
1515
bsc_flags = $bsc_no_open_flags
1616
o runtime/caml.cmj : cc_cmi runtime/caml.res | runtime/caml.cmi runtime/caml_int64_extern.cmj

jscomp/stdlib-406/release.ninja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
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
2+
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 -curried
33

44
rule cc
55
command = $bsc -bs-cmi -bs-cmj $bsc_flags -I stdlib-406 $in

jscomp/test/build.ninja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
bsc_flags = -bs-cross-module-opt -make-runtime-test -bs-package-output commonjs:jscomp/test -w -3-6-26-27-29-30-32..40-44-45-52-60-9-106+104 -warn-error A -I runtime -I $stdlib -I others
2+
bsc_flags = -bs-cross-module-opt -make-runtime-test -bs-package-output commonjs:jscomp/test -w -3-6-26-27-29-30-32..40-44-45-52-60-9-106+104 -warn-error A -I runtime -I $stdlib -I others -curried
33

44
rule cc
55
command = $bsc -bs-cmi -bs-cmj $bsc_flags -I test $in

scripts/ninja.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ async function runtimeNinja(devmode = true) {
782782
var externalDeps = devmode ? [compilerTarget] : [];
783783
var ninjaOutput = devmode ? "build.ninja" : "release.ninja";
784784
var templateRuntimeRules = `
785-
bsc_no_open_flags = ${commonBsFlags} -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A
785+
bsc_no_open_flags = ${commonBsFlags} -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A -curried
786786
bsc_flags = $bsc_no_open_flags -open Bs_stdlib_mini
787787
${ruleCC(ninjaCwd)}
788788
${ninjaQuickBuildList([
@@ -791,7 +791,7 @@ ${ninjaQuickBuildList([
791791
"bs_stdlib_mini.resi",
792792
"cc",
793793
ninjaCwd,
794-
[["bsc_flags", "-nostdlib -nopervasives"]],
794+
[["bsc_flags", "-nostdlib -nopervasives -curried"]],
795795
[],
796796
externalDeps,
797797
],
@@ -863,7 +863,7 @@ async function othersNinja(devmode = true) {
863863
var ninjaCwd = "others";
864864

865865
var templateOthersRules = `
866-
bsc_primitive_flags = ${commonBsFlags} -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A
866+
bsc_primitive_flags = ${commonBsFlags} -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A -curried
867867
bsc_flags = $bsc_primitive_flags -open Belt_internals
868868
${ruleCC(ninjaCwd)}
869869
${ninjaQuickBuildList([
@@ -970,7 +970,7 @@ async function stdlibNinja(devmode = true) {
970970
// deprecations diabled due to string_of_float
971971
var warnings = "-w -9-3-106 -warn-error A";
972972
var templateStdlibRules = `
973-
${bsc_flags} = ${commonBsFlags} -bs-cross-module-opt -make-runtime ${warnings} -I others
973+
${bsc_flags} = ${commonBsFlags} -bs-cross-module-opt -make-runtime ${warnings} -I others -curried
974974
${ruleCC(ninjaCwd)}
975975
${ninjaQuickBuildList([
976976
// we make it still depends on external
@@ -1083,7 +1083,7 @@ async function testNinja() {
10831083
var ninjaOutput = "build.ninja";
10841084
var ninjaCwd = `test`;
10851085
var templateTestRules = `
1086-
bsc_flags = -bs-cross-module-opt -make-runtime-test -bs-package-output commonjs:jscomp/test -w -3-6-26-27-29-30-32..40-44-45-52-60-9-106+104 -warn-error A -I runtime -I $stdlib -I others
1086+
bsc_flags = -bs-cross-module-opt -make-runtime-test -bs-package-output commonjs:jscomp/test -w -3-6-26-27-29-30-32..40-44-45-52-60-9-106+104 -warn-error A -I runtime -I $stdlib -I others -curried
10871087
${ruleCC(ninjaCwd)}
10881088
`;
10891089
var testDirFiles = fs.readdirSync(testDir, "ascii");

0 commit comments

Comments
 (0)