Skip to content
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

Back-end: emit let instead of var. #6102

Merged
merged 1 commit into from
Apr 30, 2024
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
  •  
  •  
  •  
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- Remove empty export blocks in generated js code. https://github.com/rescript-lang/rescript-compiler/pull/6744
- Fix indent for returned/thrown/wrapped in parentheses objects in generated js code. https://github.com/rescript-lang/rescript-compiler/pull/6746
- Fix indent in generated js code. https://github.com/rescript-lang/rescript-compiler/pull/6747
- In generated code, use `let` instead of `var`. https://github.com/rescript-lang/rescript-compiler/pull/6102

# 11.1.0

Expand Down
2 changes: 1 addition & 1 deletion jscomp/build_tests/custom_namespace/src/demo.bs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';


var v = 42;
let v = 42;

exports.v = v;
/* No side effect */
2 changes: 1 addition & 1 deletion jscomp/build_tests/devonly/src/demo.bs.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/build_tests/devonly/src/depdemo.bs.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/build_tests/devonly/src2/hello.bs.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/build_tests/devonly/src2/hellodep.bs.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/build_tests/ns/src/demo.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/build_tests/ns/src/hello.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/build_tests/react_ppx/src/React.bs.js

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

12 changes: 6 additions & 6 deletions jscomp/build_tests/react_ppx/src/gpr_3695_test.bs.js

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

44 changes: 22 additions & 22 deletions jscomp/build_tests/react_ppx/src/gpr_3987_test.bs.js

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

18 changes: 9 additions & 9 deletions jscomp/build_tests/react_ppx/src/recursive_component_test.bs.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/core/js_dump.ml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ let pp_paren_params (inner_cxt : cxt) (f : Ext_pp.t) (lexical : Ident.t list) :
id) *)

let pp_var_assign cxt f id =
P.string f L.var;
P.string f L.let_;
P.space f;
let acxt = Ext_pp_scope.ident cxt f id in
P.space f;
Expand All @@ -199,7 +199,7 @@ let pp_var_assign_this cxt f id =
cxt

let pp_var_declare cxt f id =
P.string f L.var;
P.string f L.let_;
P.space f;
let acxt = Ext_pp_scope.ident cxt f id in
semi f;
Expand Down
2 changes: 1 addition & 1 deletion jscomp/core/js_dump_import_export.ml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ let requires require_lit cxt f (modules : (Ident.t * string * bool) list) =
in
P.at_least_two_lines f;
Ext_list.rev_iter reversed_list (fun (s, file, default) ->
P.string f L.var;
P.string f L.let_;
P.space f;
P.string f s;
P.space f;
Expand Down
2 changes: 1 addition & 1 deletion jscomp/core/js_dump_lit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let function_ = "function"

let function_async ~async = if async then "async function" else "function"

let var = "var" (* should be able to switch to [let] easily*)
let let_ = "let"

let return = "return"

Expand Down

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

22 changes: 11 additions & 11 deletions jscomp/test/406_primitive_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/AsInUncurriedExternals.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/Coercion.js

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

Loading
Loading