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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
28 changes: 24 additions & 4 deletions jscomp/core/js_dump.ml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@ let pp_var_assign cxt id =
space cxt;
acxt

let pp_const_assign cxt id =
string cxt "const";
space cxt;
let acxt = ident cxt id in
space cxt;
string cxt L.eq;
space cxt;
acxt

let pp_var_assign_this cxt id =
let cxt = pp_var_assign cxt id in
string cxt L.this;
Expand Down Expand Up @@ -333,6 +342,11 @@ let block_has_all_int_fields =
!r
with Local r -> r

let pp_assign ~(property : Lam_group.let_kind) cxt name =
match property with
| Variable -> pp_var_assign cxt name
| Strict | Alias | StrictOpt -> pp_const_assign cxt name

(* TODO: refactoring
Note that {!pp_function} could print both statement and expression when [No_name] is given
*)
Expand Down Expand Up @@ -383,7 +397,7 @@ and pp_function ~return_unit ~is_method cxt ~fn_state (l : Ident.t list)
(* length *)
match fn_state with
| Name_top i | Name_non_top i ->
let cxt = pp_var_assign cxt i in
let cxt = pp_const_assign cxt i in
let cxt = optimize len ~p:(arity = NA && len <= 8) cxt v in
semi cxt;
cxt
Expand Down Expand Up @@ -444,7 +458,7 @@ and pp_function ~return_unit ~is_method cxt ~fn_state (l : Ident.t list)
space cxt;
param_body ())
| Name_non_top x ->
ignore (pp_var_assign inner_cxt x : cxt);
ignore (pp_const_assign inner_cxt x : cxt);
string cxt L.function_;
space cxt;
param_body ();
Expand Down Expand Up @@ -894,7 +908,13 @@ and variable_declaration top cxt (variable : J.variable_declaration) : cxt =
match variable with
| { ident = i; value = None; ident_info; _ } ->
if ident_info.used_stats = Dead_pure then cxt else pp_var_declare cxt i
| { ident = name; value = Some e; ident_info = { used_stats; _ }; _ } -> (
| {
ident = name;
value = Some e;
ident_info = { used_stats; _ };
property;
_;
} -> (
match used_stats with
| Dead_pure -> cxt
| Dead_non_pure ->
Expand All @@ -907,7 +927,7 @@ and variable_declaration top cxt (variable : J.variable_declaration) : cxt =
~fn_state:(if top then Name_top name else Name_non_top name)
params b env
| _ ->
let cxt = pp_var_assign cxt name in
let cxt = pp_assign ~property cxt name in
let cxt = expression ~level:1 cxt e in
semi cxt;
cxt))
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/dist-es6/jscomp/test/es6_tests/es6_export.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Generated by Melange


let $$default = 3;
const $$default = 3;

export {
$$default as default,
Expand Down
34 changes: 17 additions & 17 deletions jscomp/test/dist-es6/jscomp/test/mt.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ function assert_fail(msg) {
}

function is_mocha(param) {
let match = Stdlib__Array.to_list(Process.argv);
const match = Stdlib__Array.to_list(Process.argv);
if (!match) {
return false;
}
let match$1 = match.tl;
const match$1 = match.tl;
if (!match$1) {
return false;
}
let exec = Path.basename(match$1.hd);
const exec = Path.basename(match$1.hd);
if (exec === "mocha") {
return true;
} else {
Expand All @@ -29,11 +29,11 @@ function is_mocha(param) {
}

function from_suites(name, suite) {
let match = Stdlib__Array.to_list(Process.argv);
const match = Stdlib__Array.to_list(Process.argv);
if (match && is_mocha(undefined)) {
describe(name, (function () {
return Stdlib__List.iter((function (param) {
let partial_arg = param[1];
const partial_arg = param[1];
it(param[0], (function () {
return Curry._1(partial_arg, undefined);
}));
Expand All @@ -45,7 +45,7 @@ function from_suites(name, suite) {
}

function close_enough(thresholdOpt, a, b) {
let threshold = thresholdOpt !== undefined ? thresholdOpt : 0.0000001;
const threshold = thresholdOpt !== undefined ? thresholdOpt : 0.0000001;
return Math.abs(a - b) < threshold;
}

Expand All @@ -67,17 +67,17 @@ function handleCode(spec) {
Assert.ok(spec._0);
return ;
case /* Approx */5 :
let b = spec._1;
let a = spec._0;
const b = spec._1;
const a = spec._0;
if (!close_enough(undefined, a, b)) {
Assert.deepEqual(a, b);
return ;
} else {
return ;
}
case /* ApproxThreshold */6 :
let b$1 = spec._2;
let a$1 = spec._1;
const b$1 = spec._2;
const a$1 = spec._1;
if (!close_enough(spec._0, a$1, b$1)) {
Assert.deepEqual(a$1, b$1);
return ;
Expand All @@ -96,12 +96,12 @@ function handleCode(spec) {
}

function from_pair_suites(name, suites) {
let match = Stdlib__Array.to_list(Process.argv);
const match = Stdlib__Array.to_list(Process.argv);
if (match) {
if (is_mocha(undefined)) {
describe(name, (function () {
return Stdlib__List.iter((function (param) {
let code = param[1];
const code = param[1];
it(param[0], (function () {
return handleCode(Curry._1(code, undefined));
}));
Expand All @@ -114,8 +114,8 @@ function from_pair_suites(name, suites) {
"testing"
]);
return Stdlib__List.iter((function (param) {
let name = param[0];
let _fn = Curry._1(param[1], undefined);
const name = param[0];
const _fn = Curry._1(param[1], undefined);
switch (_fn.TAG | 0) {
case /* Eq */0 :
console.log([
Expand Down Expand Up @@ -191,15 +191,15 @@ function from_pair_suites(name, suites) {

}

let val_unit = Promise.resolve(undefined);
const val_unit = Promise.resolve(undefined);

function from_promise_suites(name, suites) {
let match = Stdlib__Array.to_list(Process.argv);
const match = Stdlib__Array.to_list(Process.argv);
if (match) {
if (is_mocha(undefined)) {
describe(name, (function () {
return Stdlib__List.iter((function (param) {
let code = param[1];
const code = param[1];
it(param[0], (function () {
return code.then(function (x) {
handleCode(x);
Expand Down
14 changes: 7 additions & 7 deletions jscomp/test/dist/jscomp/test/406_primitive_test.js

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

4 changes: 2 additions & 2 deletions jscomp/test/dist/jscomp/test/a_filename_test.js

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

6 changes: 3 additions & 3 deletions jscomp/test/dist/jscomp/test/a_list_test.js

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

6 changes: 3 additions & 3 deletions jscomp/test/dist/jscomp/test/a_recursive_type.js

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

8 changes: 4 additions & 4 deletions jscomp/test/dist/jscomp/test/a_scope_bug.js

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

10 changes: 5 additions & 5 deletions jscomp/test/dist/jscomp/test/a_string_test.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/dist/jscomp/test/acyc/a0_a1.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/dist/jscomp/test/acyc/a1_a2.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/dist/jscomp/test/acyc/a2_a3.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/dist/jscomp/test/acyc/a3_a4.js

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

Loading