Skip to content
Merged
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
2 changes: 2 additions & 0 deletions jscomp/test/build.ninja
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ o test/gpr_4900_test.cmi test/gpr_4900_test.cmj : cc test/gpr_4900_test.ml | tes
o test/gpr_4924_test.cmi test/gpr_4924_test.cmj : cc test/gpr_4924_test.ml | test/mt.cmj $stdlib
o test/gpr_4931.cmi test/gpr_4931.cmj : cc test/gpr_4931.ml | $stdlib
o test/gpr_5071_test.cmi test/gpr_5071_test.cmj : cc test/gpr_5071_test.res | test/react.cmj $stdlib
o test/gpr_5169_test.cmi test/gpr_5169_test.cmj : cc test/gpr_5169_test.ml | $stdlib
o test/gpr_627_test.cmi test/gpr_627_test.cmj : cc test/gpr_627_test.ml | test/mt.cmj $stdlib
o test/gpr_658.cmi test/gpr_658.cmj : cc test/gpr_658.ml | $stdlib
o test/gpr_858_test.cmi test/gpr_858_test.cmj : cc test/gpr_858_test.ml | $stdlib
Expand Down Expand Up @@ -471,6 +472,7 @@ o test/ocaml_re_test.cmi test/ocaml_re_test.cmj : cc test/ocaml_re_test.ml | tes
o test/of_string_test.cmi test/of_string_test.cmj : cc test/of_string_test.ml | test/mt.cmj $stdlib
o test/offset.cmi test/offset.cmj : cc test/offset.ml | $stdlib
o test/oo_js_test_date.cmi test/oo_js_test_date.cmj : cc test/oo_js_test_date.ml | test/mt.cmj $stdlib
o test/option_encoding_test.cmi test/option_encoding_test.cmj : cc test/option_encoding_test.ml | $stdlib
o test/option_repr_test.cmi test/option_repr_test.cmj : cc test/option_repr_test.ml | test/mt.cmj $stdlib
o test/optional_ffi_test.cmi test/optional_ffi_test.cmj : cc test/optional_ffi_test.ml | test/mt.cmj $stdlib
o test/optional_regression_test.cmi test/optional_regression_test.cmj : cc test/optional_regression_test.ml | test/mt.cmj $stdlib
Expand Down
53 changes: 53 additions & 0 deletions jscomp/test/gpr_5169_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
'use strict';


var NotOption = {};

var TotallyNotOption = {};

var NotOption2 = {};

var a;

var b = 1;

var c;

var d = 1;

var e;

var f = 1;

var g;

var h = 1;

var i = /* None */0;

var j = /* Some */{
_0: 1
};

var k = /* None */0;

var l = /* Some */{
_0: 1
};

exports.NotOption = NotOption;
exports.a = a;
exports.b = b;
exports.c = c;
exports.d = d;
exports.TotallyNotOption = TotallyNotOption;
exports.e = e;
exports.f = f;
exports.g = g;
exports.h = h;
exports.NotOption2 = NotOption2;
exports.i = i;
exports.j = j;
exports.k = k;
exports.l = l;
/* No side effect */
29 changes: 29 additions & 0 deletions jscomp/test/gpr_5169_test.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module NotOption = struct

type 'a t = None | Some of 'a
end

let a = NotOption.None (* undefined *)
let b = NotOption.Some(1) (* 1 *)
let c = let open NotOption in None
let d = let open NotOption in Some(1)


module TotallyNotOption = struct
type 'a t = Some of ('a) | None
end

let e = TotallyNotOption.None (* undefined *)
let f = TotallyNotOption.Some(1) (* 1 *)
let g = let open TotallyNotOption in None
let h = let open TotallyNotOption in Some(1)


module NotOption2 = struct
type 'a t = None | Some of 'a | Bogus
end

let i = NotOption2.None
let j = NotOption2.Some(1)
let k = let open NotOption2 in None
let l = let open NotOption2 in Some(1)
16 changes: 16 additions & 0 deletions jscomp/test/option_encoding_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';


var N = {};

var u = [
undefined,
3
];

var h;

exports.N = N;
exports.u = u;
exports.h = h;
/* No side effect */
24 changes: 24 additions & 0 deletions jscomp/test/option_encoding_test.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[@@@config {
flags = [|
"-w";
"@A";
"-drawlambda";
"-dtypedtree";
"-bs-diagnose";
"-dparsetree";
(* "-dsource"; *)
|]
}]


module N = struct
type 'a t = 'a option =
| None
| Some of 'a
end


let u = N.(None, Some 3)


let h = N.None
4 changes: 3 additions & 1 deletion lib/4.06.1/unstable/js_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -71820,7 +71820,9 @@ and transl_exp0 e =
| Longident.Lident "None"
when Datarepr.constructor_has_optional_shape cstr
-> Pt_shape_none
| _ -> Pt_constructor {name = cstr.cstr_name; const = cstr.cstr_consts; non_const = cstr.cstr_nonconsts}
| _ ->
if Datarepr.constructor_has_optional_shape cstr then Pt_shape_none
else Pt_constructor {name = cstr.cstr_name; const = cstr.cstr_consts; non_const = cstr.cstr_nonconsts}
))
| Cstr_unboxed ->
(match ll with [v] -> v | _ -> assert false)
Expand Down
4 changes: 3 additions & 1 deletion lib/4.06.1/whole_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -355863,7 +355863,9 @@ and transl_exp0 e =
| Longident.Lident "None"
when Datarepr.constructor_has_optional_shape cstr
-> Pt_shape_none
| _ -> Pt_constructor {name = cstr.cstr_name; const = cstr.cstr_consts; non_const = cstr.cstr_nonconsts}
| _ ->
if Datarepr.constructor_has_optional_shape cstr then Pt_shape_none
else Pt_constructor {name = cstr.cstr_name; const = cstr.cstr_consts; non_const = cstr.cstr_nonconsts}
))
| Cstr_unboxed ->
(match ll with [v] -> v | _ -> assert false)
Expand Down
50 changes: 38 additions & 12 deletions scripts/ninja.js
Original file line number Diff line number Diff line change
Expand Up @@ -1420,8 +1420,10 @@ function test(dir) {
return (
(x.endsWith(".ml") || x.endsWith(".mli")) &&
!(x.endsWith(".cppo.ml") || x.endsWith(".cppo.mli")) &&
!x.includes('bytelibrarian') && !x.includes('bytelink') &&
!x.includes('bytepackager') && !x.includes('emitcode')
!x.includes("bytelibrarian") &&
!x.includes("bytelink") &&
!x.includes("bytepackager") &&
!x.includes("emitcode")
);
})
.map((x) => path.join(dir, x));
Expand Down Expand Up @@ -1522,7 +1524,7 @@ ${buildNapkinFiles}
`;
var cppoNinjaFile = getPreprocessorFileName();
writeFileSync(path.join(jscompDir, cppoNinjaFile), cppoNative);
cp.execFileSync(vendorNinjaPath, ["-f", cppoNinjaFile, "--verbose",'-v'], {
cp.execFileSync(vendorNinjaPath, ["-f", cppoNinjaFile, "--verbose", "-v"], {
cwd: jscompDir,
stdio: [0, 1, 2],
encoding: "utf8",
Expand Down Expand Up @@ -1557,8 +1559,9 @@ var sourceDirs = [
function makeLibs(dirs) {
return dirs.map((x) => `${x}/${x}.cmxa`).join(" ");
}
var compiler_libs = ['utils','parsing', 'typing','bytecomp']
var bsc_libs = compiler_libs.concat([
var compiler_libs = ["utils", "parsing", "typing", "bytecomp"];
var bsc_libs = [
...compiler_libs,
"js_parser",
"stubs",
"ext",
Expand All @@ -1569,20 +1572,43 @@ var bsc_libs = compiler_libs.concat([
"super_errors",
"outcome_printer",
"core",
]);

];

var bspack_libs = compiler_libs.concat(["stubs", "ext", "common", "frontend", "depends"]);
var bspack_libs = [
...compiler_libs,
"stubs",
"ext",
"common",
"frontend",
"depends",
];

var bsb_helper_libs = ["stubs", "ext", "common", "bsb_helper"];

var rescript_libs = ["stubs", "ext", "common", "bsb"];

var cmjdumps_libs = compiler_libs.concat(["stubs", "ext", "common", "frontend", "depends", "core"]);
var cmjdumps_libs = [
...compiler_libs,
"stubs",
"ext",
"common",
"frontend",
"depends",
"core",
];

var cmij_libs = compiler_libs.concat(["stubs", "ext", "common", "frontend", "depends", "core"]);
var cmij_libs = [
...compiler_libs,
"stubs",
"ext",
"common",
"frontend",
"depends",
"core",
];

var tests_libs = compiler_libs.concat([
var tests_libs = [
...compiler_libs,
"ounit",
"stubs",
"ext",
Expand All @@ -1593,7 +1619,7 @@ var tests_libs = compiler_libs.concat([
"bsb_helper",
"core",
"ounit_tests",
]);
];
/**
* Note don't run `ninja -t clean -g`
* Since it will remove generated ml file which has
Expand Down