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

Fix indent for returned/thrown/wrapped in parentheses objects in generated js code #6746

Merged
merged 5 commits into from
Apr 28, 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 @@ -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.

Loading
Loading