Skip to content

Audit what files are compiled in curried mode. #6853

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
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
13 changes: 11 additions & 2 deletions jscomp/bsc/rescript_compiler_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ let setup_runtime_path path =
Bs_version.package_name := std);
Js_config.customize_runtime := Some path

let curry_specified = ref false


let process_file sourcefile ?(kind ) ppf =
(* This is a better default then "", it will be changed later
Expand All @@ -46,6 +48,11 @@ let process_file sourcefile ?(kind ) ppf =
match kind with
| None -> Ext_file_extensions.classify_input (Ext_filename.get_extension_maybe sourcefile)
| Some kind -> kind in
(if !curry_specified = false && !Clflags.dump_source = false && !Js_config.syntax_only = false && List.mem kind [Res; Resi] then
let _ = Printf.eprintf "XXX curry not specified %s\n%!" sourcefile in
let _ = assert false in
()
);
let res = match kind with
| Res ->
let sourcefile = set_abs_input_name sourcefile in
Expand Down Expand Up @@ -406,8 +413,10 @@ 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 () -> curry_specified := true; Config.uncurried := Uncurried),
"*internal*";
"-curried", unit_call (fun () -> curry_specified := true; Config.uncurried := Legacy),
"*internal*";
"-v", unit_call print_version_string,
"Print compiler version and location of standard library and exit";

Expand Down
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`;
const prefix = `${bsc} -w +A -curried`;

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

Expand Down
6 changes: 3 additions & 3 deletions jscomp/others/js_promise.res
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type error
*/

@new
external make: ((@uncurry ~resolve: (. 'a) => unit, ~reject: (. exn) => unit) => unit) => promise<
external make: ((~resolve: (. 'a) => unit, ~reject: (. exn) => unit) => unit) => promise<
'a,
> = "Promise"

Expand Down Expand Up @@ -83,12 +83,12 @@ external all6: (

@val @scope("Promise") external race: array<promise<'a>> => promise<'a> = "race"

@send external then_: (promise<'a>, @uncurry ('a => promise<'b>)) => promise<'b> = "then"
@send external then_: (promise<'a>, ('a => promise<'b>)) => promise<'b> = "then"
let then_ = (arg1, obj) => then_(obj, arg1)


@send
external catch: (promise<'a>, @uncurry (error => promise<'a>)) => promise<'a> = "catch"
external catch: (promise<'a>, (error => promise<'a>)) => promise<'a> = "catch"
let catch = (arg1, obj) => catch(obj, arg1)
/* ` p|> catch handler`
Note in JS the returned promise type is actually runtime dependent,
Expand Down
2 changes: 1 addition & 1 deletion jscomp/others/js_promise2.res
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let catch: (promise<'a>, error => promise<'a>) => promise<'a> = %raw(`
`)

@new
external make: ((@uncurry ~resolve: (. 'a) => unit, ~reject: (. exn) => unit) => unit) => promise<
external make: ((~resolve: (. 'a) => unit, ~reject: (. exn) => unit) => unit) => promise<
'a,
> = "Promise"

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
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
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
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
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
bsc_flags = -nostdlib -nopervasives -curried
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
14 changes: 8 additions & 6 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
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

rule cc
command = $bsc -bs-cmi -bs-cmj $bsc_flags -I stdlib-406 $in
Expand All @@ -9,9 +9,13 @@ 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
bsc_flags = $bsc_flags -nopervasives -curried
o stdlib-406/pervasives.cmi : cc stdlib-406/pervasives.resi | $bsc others
bsc_flags = $bsc_flags -nopervasives
bsc_flags = $bsc_flags -nopervasives -curried
o stdlib-406/pervasivesU.cmj : cc_cmi stdlib-406/pervasivesU.res | stdlib-406/pervasivesU.cmi $bsc others
bsc_flags = $bsc_flags -nopervasives -curried
o stdlib-406/pervasivesU.cmi : cc stdlib-406/pervasivesU.resi | $bsc others
bsc_flags = $bsc_flags -nopervasives -curried
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
o stdlib-406/array.cmj : cc_cmi stdlib-406/array.res | stdlib-406/array.cmi $bsc others
Expand Down Expand Up @@ -64,8 +68,6 @@ o stdlib-406/obj.cmj : cc_cmi stdlib-406/obj.res | stdlib-406/obj.cmi $bsc other
o stdlib-406/obj.cmi : cc stdlib-406/obj.resi | stdlib-406/pervasives.cmj $bsc others
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
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/pervasivesU.cmj : cc_cmi stdlib-406/pervasivesU.res | stdlib-406/pervasivesU.cmi $bsc others
o stdlib-406/pervasivesU.cmi : cc stdlib-406/pervasivesU.resi | 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
Expand All @@ -89,4 +91,4 @@ o stdlib-406/sys.cmj : cc_cmi stdlib-406/sys.res | stdlib-406/sys.cmi $bsc other
o stdlib-406/sys.cmi : cc stdlib-406/sys.resi | stdlib-406/pervasives.cmj $bsc others
o stdlib-406/uchar.cmj : cc_cmi stdlib-406/uchar.res | stdlib-406/char.cmj stdlib-406/uchar.cmi $bsc others
o stdlib-406/uchar.cmi : cc stdlib-406/uchar.resi | stdlib-406/pervasives.cmj $bsc others
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
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
8 changes: 3 additions & 5 deletions jscomp/test/Import.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions jscomp/test/SafePromises.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jscomp/test/build.ninja
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

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
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

rule cc
command = $bsc -bs-cmi -bs-cmj $bsc_flags -I test $in
Expand Down
22 changes: 5 additions & 17 deletions jscomp/test/mt.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions jscomp/test/mt.res
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function from_suites(name, suite) {
return List.iter((function (param) {
var partial_arg = param[1];
it(param[0], (function () {
return Curry._1(partial_arg, undefined);
return partial_arg(undefined);
}));
}), suite);
}));
Expand Down Expand Up @@ -118,11 +118,6 @@ let handleCode = spec =>
| FailWith(msg) => assert_fail(msg)
}

let force_curry = x => {
let _ = List.hd(list{3})
let _ = Array.copy([5])
x()
}
let from_pair_suites = %raw(`
function from_pair_suites(name, suites) {
var match = $$Array.to_list(Process.argv);
Expand All @@ -132,7 +127,7 @@ function from_pair_suites(name, suites) {
return List.iter((function (param) {
var code = param[1];
it(param[0], (function () {
return handleCode(Curry._1(code, undefined));
return handleCode(code(undefined));
}));
}), suites);
}));
Expand All @@ -144,7 +139,7 @@ function from_pair_suites(name, suites) {
]);
return List.iter((function (param) {
var name = param[0];
var fn = Curry._1(param[1], undefined);
var fn = param[1](undefined);
switch (fn.TAG) {
case "Eq" :
console.log([
Expand Down
2 changes: 0 additions & 2 deletions jscomp/test/mt.resi
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,3 @@ let eq_suites: (~test_id: ref<int>, ~suites: ref<pair_suites>, string, 'b, 'b) =
let bool_suites: (~test_id: ref<int>, ~suites: ref<pair_suites>, string, bool) => unit

let throw_suites: (~test_id: ref<int>, ~suites: ref<pair_suites>, string, unit => unit) => unit

let force_curry: (unit => unit) => unit
Loading