Skip to content

Commit

Permalink
fix(grainfmt): Group infix functions when passed as params
Browse files Browse the repository at this point in the history
Added a group around infix functions when passed as args to keep the break outside the function applications
  • Loading branch information
marcusroberts authored Oct 6, 2021
1 parent 4e739f1 commit bb9666d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
17 changes: 9 additions & 8 deletions compiler/grainformat/reformat.re
Original file line number Diff line number Diff line change
Expand Up @@ -1200,14 +1200,15 @@ and print_application =
} else {
right_expr;
};

Doc.concat([
Doc.group(wrapped_left),
Doc.space,
Doc.text(function_name),
Doc.line,
Doc.group(wrapped_right),
]);
Doc.group(
Doc.concat([
Doc.group(wrapped_left),
Doc.space,
Doc.text(function_name),
Doc.line,
Doc.group(wrapped_right),
]),
);

| _ when prefixop(function_name) || infixop(function_name) =>
raise(Error(Illegal_parse("Formatter error, wrong number of args ")))
Expand Down
7 changes: 7 additions & 0 deletions compiler/test/formatter_inputs/application.gr
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@ export let unique = array => {
export let batchActionCreateAccount = ({index}) => {
Native.promiseBatchActionCreateAccount(Conv.fromInt64(index))
}


let ret = filteri(
dst + _VALUE_OFFSET + dstIndex,
src + _VALUE_OFFSET + srcIndex,
length,
)
6 changes: 6 additions & 0 deletions compiler/test/formatter_outputs/application.gr
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@ export let unique = array => {
export let batchActionCreateAccount = ({ index }) => {
Native.promiseBatchActionCreateAccount(Conv.fromInt64(index))
}

let ret = filteri(
dst + _VALUE_OFFSET + dstIndex,
src + _VALUE_OFFSET + srcIndex,
length,
)

0 comments on commit bb9666d

Please sign in to comment.