Skip to content

Commit ed69155

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 94ac53e commit ed69155

File tree

7 files changed

+54
-21
lines changed

7 files changed

+54
-21
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: 1 addition & 1 deletion
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

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: 8 additions & 6 deletions
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
@@ -9,9 +9,13 @@ rule cc_cmi
99
description = $in -> $out
1010

1111
o stdlib-406/pervasives.cmj : cc_cmi stdlib-406/pervasives.res | stdlib-406/pervasives.cmi $bsc others
12-
bsc_flags = $bsc_flags -nopervasives
12+
bsc_flags = $bsc_flags -nopervasives -curried
1313
o stdlib-406/pervasives.cmi : cc stdlib-406/pervasives.resi | $bsc others
14-
bsc_flags = $bsc_flags -nopervasives
14+
bsc_flags = $bsc_flags -nopervasives -curried
15+
o stdlib-406/pervasivesU.cmj : cc_cmi stdlib-406/pervasivesU.res | stdlib-406/pervasivesU.cmi $bsc others
16+
bsc_flags = $bsc_flags -nopervasives -curried
17+
o stdlib-406/pervasivesU.cmi : cc stdlib-406/pervasivesU.resi | $bsc others
18+
bsc_flags = $bsc_flags -nopervasives -curried
1519
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
1620
o stdlib-406/arg.cmi : cc stdlib-406/arg.resi | stdlib-406/pervasives.cmj $bsc others
1721
o stdlib-406/array.cmj : cc_cmi stdlib-406/array.res | stdlib-406/array.cmi $bsc others
@@ -64,8 +68,6 @@ o stdlib-406/obj.cmj : cc_cmi stdlib-406/obj.res | stdlib-406/obj.cmi $bsc other
6468
o stdlib-406/obj.cmi : cc stdlib-406/obj.resi | stdlib-406/pervasives.cmj $bsc others
6569
o stdlib-406/parsing.cmj : cc_cmi stdlib-406/parsing.res | stdlib-406/array.cmj stdlib-406/lexing.cmj stdlib-406/obj.cmj stdlib-406/parsing.cmi $bsc others
6670
o stdlib-406/parsing.cmi : cc stdlib-406/parsing.resi | stdlib-406/lexing.cmi stdlib-406/obj.cmi stdlib-406/pervasives.cmj $bsc others
67-
o stdlib-406/pervasivesU.cmj : cc_cmi stdlib-406/pervasivesU.res | stdlib-406/pervasivesU.cmi $bsc others
68-
o stdlib-406/pervasivesU.cmi : cc stdlib-406/pervasivesU.resi | stdlib-406/pervasives.cmj $bsc others
6971
o stdlib-406/queue.cmj : cc_cmi stdlib-406/queue.res | stdlib-406/queue.cmi $bsc others
7072
o stdlib-406/queue.cmi : cc stdlib-406/queue.resi | stdlib-406/pervasives.cmj $bsc others
7173
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
@@ -89,4 +91,4 @@ o stdlib-406/sys.cmj : cc_cmi stdlib-406/sys.res | stdlib-406/sys.cmi $bsc other
8991
o stdlib-406/sys.cmi : cc stdlib-406/sys.resi | stdlib-406/pervasives.cmj $bsc others
9092
o stdlib-406/uchar.cmj : cc_cmi stdlib-406/uchar.res | stdlib-406/char.cmj stdlib-406/uchar.cmi $bsc others
9193
o stdlib-406/uchar.cmi : cc stdlib-406/uchar.resi | stdlib-406/pervasives.cmj $bsc others
92-
o $stdlib : phony stdlib-406/pervasives.cmi stdlib-406/pervasives.cmj stdlib-406/arg.cmi stdlib-406/arg.cmj stdlib-406/array.cmi stdlib-406/array.cmj stdlib-406/arrayLabels.cmi stdlib-406/arrayLabels.cmj stdlib-406/buffer.cmi stdlib-406/buffer.cmj stdlib-406/bytes.cmi stdlib-406/bytes.cmj stdlib-406/bytesLabels.cmi stdlib-406/bytesLabels.cmj stdlib-406/callback.cmi stdlib-406/callback.cmj stdlib-406/camlinternalLazy.cmi stdlib-406/camlinternalLazy.cmj stdlib-406/camlinternalMod.cmi stdlib-406/camlinternalMod.cmj stdlib-406/char.cmi stdlib-406/char.cmj stdlib-406/complex.cmi stdlib-406/complex.cmj stdlib-406/digest.cmi stdlib-406/digest.cmj stdlib-406/filename.cmi stdlib-406/filename.cmj stdlib-406/genlex.cmi stdlib-406/genlex.cmj stdlib-406/hashtbl.cmi stdlib-406/hashtbl.cmj stdlib-406/hashtblLabels.cmi stdlib-406/hashtblLabels.cmj stdlib-406/int32.cmi stdlib-406/int32.cmj stdlib-406/int64.cmi stdlib-406/int64.cmj stdlib-406/lazy.cmi stdlib-406/lazy.cmj stdlib-406/lexing.cmi stdlib-406/lexing.cmj stdlib-406/list.cmi stdlib-406/list.cmj stdlib-406/listLabels.cmi stdlib-406/listLabels.cmj stdlib-406/map.cmi stdlib-406/map.cmj stdlib-406/mapLabels.cmi stdlib-406/mapLabels.cmj stdlib-406/moreLabels.cmi stdlib-406/moreLabels.cmj stdlib-406/obj.cmi stdlib-406/obj.cmj stdlib-406/parsing.cmi stdlib-406/parsing.cmj stdlib-406/pervasivesU.cmi stdlib-406/pervasivesU.cmj stdlib-406/queue.cmi stdlib-406/queue.cmj stdlib-406/random.cmi stdlib-406/random.cmj stdlib-406/set.cmi stdlib-406/set.cmj stdlib-406/setLabels.cmi stdlib-406/setLabels.cmj stdlib-406/sort.cmi stdlib-406/sort.cmj stdlib-406/stack.cmi stdlib-406/stack.cmj stdlib-406/stdLabels.cmi stdlib-406/stdLabels.cmj stdlib-406/stream.cmi stdlib-406/stream.cmj stdlib-406/string.cmi stdlib-406/string.cmj stdlib-406/stringLabels.cmi stdlib-406/stringLabels.cmj stdlib-406/sys.cmi stdlib-406/sys.cmj stdlib-406/uchar.cmi stdlib-406/uchar.cmj
94+
o $stdlib : phony stdlib-406/pervasivesU.cmi stdlib-406/pervasivesU.cmj stdlib-406/arg.cmi stdlib-406/arg.cmj stdlib-406/array.cmi stdlib-406/array.cmj stdlib-406/arrayLabels.cmi stdlib-406/arrayLabels.cmj stdlib-406/buffer.cmi stdlib-406/buffer.cmj stdlib-406/bytes.cmi stdlib-406/bytes.cmj stdlib-406/bytesLabels.cmi stdlib-406/bytesLabels.cmj stdlib-406/callback.cmi stdlib-406/callback.cmj stdlib-406/camlinternalLazy.cmi stdlib-406/camlinternalLazy.cmj stdlib-406/camlinternalMod.cmi stdlib-406/camlinternalMod.cmj stdlib-406/char.cmi stdlib-406/char.cmj stdlib-406/complex.cmi stdlib-406/complex.cmj stdlib-406/digest.cmi stdlib-406/digest.cmj stdlib-406/filename.cmi stdlib-406/filename.cmj stdlib-406/genlex.cmi stdlib-406/genlex.cmj stdlib-406/hashtbl.cmi stdlib-406/hashtbl.cmj stdlib-406/hashtblLabels.cmi stdlib-406/hashtblLabels.cmj stdlib-406/int32.cmi stdlib-406/int32.cmj stdlib-406/int64.cmi stdlib-406/int64.cmj stdlib-406/lazy.cmi stdlib-406/lazy.cmj stdlib-406/lexing.cmi stdlib-406/lexing.cmj stdlib-406/list.cmi stdlib-406/list.cmj stdlib-406/listLabels.cmi stdlib-406/listLabels.cmj stdlib-406/map.cmi stdlib-406/map.cmj stdlib-406/mapLabels.cmi stdlib-406/mapLabels.cmj stdlib-406/moreLabels.cmi stdlib-406/moreLabels.cmj stdlib-406/obj.cmi stdlib-406/obj.cmj stdlib-406/parsing.cmi stdlib-406/parsing.cmj stdlib-406/queue.cmi stdlib-406/queue.cmj stdlib-406/random.cmi stdlib-406/random.cmj stdlib-406/set.cmi stdlib-406/set.cmj stdlib-406/setLabels.cmi stdlib-406/setLabels.cmj stdlib-406/sort.cmi stdlib-406/sort.cmj stdlib-406/stack.cmi stdlib-406/stack.cmj stdlib-406/stdLabels.cmi stdlib-406/stdLabels.cmj stdlib-406/stream.cmi stdlib-406/stream.cmj stdlib-406/string.cmi stdlib-406/string.cmj stdlib-406/stringLabels.cmi stdlib-406/stringLabels.cmj stdlib-406/sys.cmi stdlib-406/sys.cmj stdlib-406/uchar.cmi stdlib-406/uchar.cmj

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: 30 additions & 8 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([
@@ -965,12 +965,14 @@ async function stdlibNinja(devmode = true) {
965965
/**
966966
* @type [string,string][]
967967
*/
968-
var bsc_builtin_overrides = [[bsc_flags, `$${bsc_flags} -nopervasives`]];
968+
var bsc_builtin_overrides = [
969+
[bsc_flags, `$${bsc_flags} -nopervasives -curried`],
970+
];
969971
// It is interesting `-w -a` would generate not great code sometimes
970972
// deprecations diabled due to string_of_float
971973
var warnings = "-w -9-3-106 -warn-error A";
972974
var templateStdlibRules = `
973-
${bsc_flags} = ${commonBsFlags} -bs-cross-module-opt -make-runtime ${warnings} -I others
975+
${bsc_flags} = ${commonBsFlags} -bs-cross-module-opt -make-runtime ${warnings} -I others -curried
974976
${ruleCC(ninjaCwd)}
975977
${ninjaQuickBuildList([
976978
// we make it still depends on external
@@ -994,21 +996,40 @@ ${ninjaQuickBuildList([
994996
[],
995997
externalDeps,
996998
],
999+
[
1000+
"pervasivesU.cmj",
1001+
"pervasivesU.res",
1002+
"cc_cmi",
1003+
ninjaCwd,
1004+
bsc_builtin_overrides,
1005+
"pervasivesU.cmi",
1006+
externalDeps,
1007+
],
1008+
[
1009+
"pervasivesU.cmi",
1010+
"pervasivesU.resi",
1011+
"cc",
1012+
ninjaCwd,
1013+
bsc_builtin_overrides,
1014+
[],
1015+
externalDeps,
1016+
],
9971017
])}
9981018
`;
9991019
var stdlibDirFiles = fs.readdirSync(stdlibDir, "ascii");
10001020
var sources = stdlibDirFiles.filter(x => {
10011021
return (
10021022
!x.startsWith("pervasives.") &&
1023+
!x.startsWith("pervasivesU.") &&
10031024
(x.endsWith(".res") || x.endsWith(".resi"))
10041025
);
10051026
});
10061027
let depsMap = new Map();
10071028
await ocamlDepForBscAsync(sources, stdlibDir, depsMap);
10081029
var targets = collectTarget(sources);
10091030
var allTargets = scanFileTargets(targets, [
1010-
"pervasives.cmi",
1011-
"pervasives.cmj",
1031+
"pervasivesU.cmi",
1032+
"pervasivesU.cmj",
10121033
]);
10131034
targets.forEach((ext, mod) => {
10141035
switch (ext) {
@@ -1083,10 +1104,11 @@ async function testNinja() {
10831104
var ninjaOutput = "build.ninja";
10841105
var ninjaCwd = `test`;
10851106
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
1107+
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
10871108
${ruleCC(ninjaCwd)}
10881109
`;
10891110
var testDirFiles = fs.readdirSync(testDir, "ascii");
1111+
//testDirFiles = [];
10901112
var sources = testDirFiles.filter(x => {
10911113
return x.endsWith(".resi") || x.endsWith(".res");
10921114
});

0 commit comments

Comments
 (0)