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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
- Fix externals whose result type is an alias of `unit` so they use the same unit-return behavior as externals declared to return `unit`. https://github.com/rescript-lang/rescript/pull/8581
- Fix dynamic imports of external bindings that require FFI argument or result conversions, including `@variadic`, `@unwrap`, polymorphic variant encodings, `@as` phantom arguments, optional labeled arguments, and `@return` wrappers. The imported value now applies the same conversions as a direct external call. https://github.com/rescript-lang/rescript/pull/8582
- Fix formatter breaking the opening brace of a functor module type's result signature onto a new line (e.g. `module Make: Pattern => {`). https://github.com/rescript-lang/rescript/pull/8519
- Fix formatter breaking an inline-record `exception` constructor onto several lines when the declaration carries a doc comment (`/** doc */ exception Foo({name: string, msg: string})`). The record argument now forms its own group, as the tuple argument already did, so the line break after the doc comment no longer propagates into the record. Inline-record type extension constructors (`type t += Ext({...})`) get the same treatment. https://github.com/rescript-lang/rescript/pull/8622
- Fix argument evaluation order when a function call is inlined: the beta reducer stacked argument bindings in reverse parameter order, so the last argument was evaluated first when arguments could not be substituted directly. https://github.com/rescript-lang/rescript/pull/8572
- Preserve parentheses around multiplication, division, and modulo expressions used as exponents. https://github.com/rescript-lang/rescript/pull/8550
- Make a function's locally abstract types (`(type t, x) => ...`) part of the function AST node instead of a chain of wrapper nodes. Fixes the formatter dropping the association of attributes with their `type` group (`(@attr type t, x, @attr2 type s, y)` used to print as `@attr @attr2` on the function) and comments written next to a type parameter migrating onto the following value parameter. https://github.com/rescript-lang/rescript/pull/8574
Expand Down
2 changes: 1 addition & 1 deletion compiler/syntax/src/res_printer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1862,7 +1862,7 @@ and print_constructor_arguments ?(is_dot_dot_dot = false) ~state ~indent
Doc.rparen;
]
in
if indent then Doc.indent args else args
Doc.group (if indent then Doc.indent args else args)

and print_label_declaration ?inline_record_definitions ~state
(ld : Parsetree.label_declaration) cmt_tbl =
Expand Down
5 changes: 5 additions & 0 deletions tests/syntax_tests/data/printer/signature/exception.resi
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ exception ExitEarly
exception Exit = Terminate
exception Exit = Lib.Terminate
exception Exit = Ns.Lib.Terminate

/** doc comment */
exception ExitEarly({x: int})
/** doc comment */
exception ExitEarly({x: int, y: string})
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ exception Exit
exception Exit = Terminate
exception Exit = Lib.Terminate
exception Exit = Ns.Lib.Terminate

/** doc comment */
exception ExitEarly({x: int})
/** doc comment */
exception ExitEarly({x: int, y: string})
7 changes: 7 additions & 0 deletions tests/syntax_tests/data/printer/structure/exception.res
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,10 @@ exception Exit = Terminate
@onConstructor
exception Exit = Lib.Terminate
exception GadtExit(int): exit<int>

/** doc comment */
exception ExitEarly({x: int})
/** doc comment */
exception ExitEarly({x: int, y: string})
/** doc comment */
exception ExitEarlyWithManyFields({firstFieldName: int, secondFieldName: string, thirdFieldName: bool, fourthFieldName: float})
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,15 @@ exception Exit = Ns.Lib.Terminate
@onConstructor exception Exit = Terminate
@onConstructor exception Exit = Lib.Terminate
exception GadtExit(int): exit<int>

/** doc comment */
exception ExitEarly({x: int})
/** doc comment */
exception ExitEarly({x: int, y: string})
/** doc comment */
exception ExitEarlyWithManyFields({
firstFieldName: int,
secondFieldName: string,
thirdFieldName: bool,
fourthFieldName: float,
})
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,7 @@ module type Tid = {
| Uid: Tid.u<t>
| Uid2: Tid.u<t>
}

type t +=
| /** doc comment */
Ext({name: string, msg: string})
2 changes: 2 additions & 0 deletions tests/syntax_tests/data/printer/structure/typeExtension.res
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,5 @@ module type Tid = {
| Uid: Tid.u<t>
| Uid2: Tid.u<t>
}

type t += /** doc comment */ Ext({name: string, msg: string})
Loading