Skip to content

Commit

Permalink
Fix indent for returned/thrown/wrapped in parentheses objects in gene…
Browse files Browse the repository at this point in the history
…rated js code (#6746)

* Remove redundant spaces for objects in paranthes

* Update test's generated files

* Fix indent for return and throw

* Update test's generated files

* Update changelog
  • Loading branch information
DZakh committed Apr 28, 2024
1 parent 17804a4 commit 4738476
Show file tree
Hide file tree
Showing 491 changed files with 33,074 additions and 33,076 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- Remove redundant space for empty return in generated js code. https://github.com/rescript-lang/rescript-compiler/pull/6745
- Remove redundant space for export in generated js code. https://github.com/rescript-lang/rescript-compiler/pull/6560
- 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

# 11.1.0

Expand Down
9 changes: 3 additions & 6 deletions jscomp/core/js_dump.ml
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ module Curry_gen = struct
P.string f (Printf.sprintf "%d" len)
end

let return_indent = String.length L.return / Ext_pp.indent_length
let throw_indent = String.length L.throw / Ext_pp.indent_length

type cxt = Ext_pp_scope.t

let semi f = P.string f L.semi
Expand Down Expand Up @@ -919,7 +916,7 @@ and expression_desc cxt ~(level : int) f x : cxt =
var f = { x : 2 , y : 2}
]}
*)
P.cond_paren_group f (level > 1) 1 (fun _ ->
P.cond_paren_group f (level > 1) 0 (fun _ ->
if lst = [] then (
P.string f "{}";
cxt)
Expand Down Expand Up @@ -1211,7 +1208,7 @@ and statement_desc top cxt f (s : J.statement_desc) : cxt =
| _ ->
return_sp f;
(* P.string f "return ";(\* ASI -- when there is a comment*\) *)
P.group f return_indent (fun _ ->
P.group f 0 (fun _ ->
let cxt = expression ~level:0 cxt f e in
semi f;
cxt)
Expand Down Expand Up @@ -1261,7 +1258,7 @@ and statement_desc top cxt f (s : J.statement_desc) : cxt =
in
P.string f L.throw;
P.space f;
P.group f throw_indent (fun _ ->
P.group f 0 (fun _ ->
let cxt = expression ~level:0 cxt f e in
semi f;
cxt)
Expand Down
8 changes: 4 additions & 4 deletions jscomp/test/406_primitive_test.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/AsInUncurriedExternals.js

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

14 changes: 7 additions & 7 deletions jscomp/test/DerivingAccessorsCurried.js

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

14 changes: 7 additions & 7 deletions jscomp/test/DerivingAccessorsUncurried.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/EmptyRecord.js

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

30 changes: 15 additions & 15 deletions jscomp/test/Import.js

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

50 changes: 25 additions & 25 deletions jscomp/test/UncurriedAlways.js

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

16 changes: 8 additions & 8 deletions jscomp/test/UncurriedExternals.js

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

30 changes: 15 additions & 15 deletions jscomp/test/UntaggedVariants.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/a_filename_test.js

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

0 comments on commit 4738476

Please sign in to comment.