Skip to content

Commit 4738476

Browse files
authored
Fix indent for returned/thrown/wrapped in parentheses objects in generated 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
1 parent 17804a4 commit 4738476

File tree

491 files changed

+33074
-33076
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

491 files changed

+33074
-33076
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
- Remove redundant space for empty return in generated js code. https://github.com/rescript-lang/rescript-compiler/pull/6745
3030
- Remove redundant space for export in generated js code. https://github.com/rescript-lang/rescript-compiler/pull/6560
3131
- Remove empty export blocks in generated js code. https://github.com/rescript-lang/rescript-compiler/pull/6744
32+
- Fix indent for returned/thrown/wrapped in parentheses objects in generated js code. https://github.com/rescript-lang/rescript-compiler/pull/6746
3233

3334
# 11.1.0
3435

jscomp/core/js_dump.ml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ module Curry_gen = struct
9292
P.string f (Printf.sprintf "%d" len)
9393
end
9494

95-
let return_indent = String.length L.return / Ext_pp.indent_length
96-
let throw_indent = String.length L.throw / Ext_pp.indent_length
97-
9895
type cxt = Ext_pp_scope.t
9996

10097
let semi f = P.string f L.semi
@@ -919,7 +916,7 @@ and expression_desc cxt ~(level : int) f x : cxt =
919916
var f = { x : 2 , y : 2}
920917
]}
921918
*)
922-
P.cond_paren_group f (level > 1) 1 (fun _ ->
919+
P.cond_paren_group f (level > 1) 0 (fun _ ->
923920
if lst = [] then (
924921
P.string f "{}";
925922
cxt)
@@ -1211,7 +1208,7 @@ and statement_desc top cxt f (s : J.statement_desc) : cxt =
12111208
| _ ->
12121209
return_sp f;
12131210
(* P.string f "return ";(\* ASI -- when there is a comment*\) *)
1214-
P.group f return_indent (fun _ ->
1211+
P.group f 0 (fun _ ->
12151212
let cxt = expression ~level:0 cxt f e in
12161213
semi f;
12171214
cxt)
@@ -1261,7 +1258,7 @@ and statement_desc top cxt f (s : J.statement_desc) : cxt =
12611258
in
12621259
P.string f L.throw;
12631260
P.space f;
1264-
P.group f throw_indent (fun _ ->
1261+
P.group f 0 (fun _ ->
12651262
let cxt = expression ~level:0 cxt f e in
12661263
semi f;
12671264
cxt)

jscomp/test/406_primitive_test.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/AsInUncurriedExternals.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/DerivingAccessorsCurried.js

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/DerivingAccessorsUncurried.js

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/EmptyRecord.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/Import.js

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/UncurriedAlways.js

Lines changed: 25 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/UncurriedExternals.js

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/UntaggedVariants.js

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/a_filename_test.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)