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

🎉 Trailing commas 🎉 #1775

Merged
merged 5 commits into from
Jan 25, 2018
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
26 changes: 15 additions & 11 deletions formatTest/typeCheckedTests/expected_output/attributes.re
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type attributedInt = [@onTopLevelTypeDef] int;
[@itemAttributeOnTypeDef]
type attributedIntsInTuple = (
[@onInt] int,
[@onFloat] float
[@onFloat] float,
);

type myDataType('x, 'y) =
Expand All @@ -58,7 +58,7 @@ type myType =
[@onEntireType]
myDataType(
[@onOptionInt] option(int),
[@onOption] option(float)
[@onOption] option(float),
);

let thisInst: myType =
Expand All @@ -69,7 +69,7 @@ let thisInst: myType =
[@attOnEntireDatatype]
MyDataType(
[@onFirstParam] Some(10),
Some(10.0)
Some(10.0),
);

let x = [@onHello] "hello";
Expand Down Expand Up @@ -145,7 +145,8 @@ let both = [@onEntireFunction] (a => a);
let both = (a, b) =>
[@onEverything] ([@onA] a && b);

let both = (a, b) => [@onA] a && [@onB] [@onB] b;
let both = (a, b) =>
[@onA] a && [@onB] [@onB] b;

let both = (a, b) => [@onEverything] (a && b);

Expand Down Expand Up @@ -191,15 +192,15 @@ let result =
[@onRecordFunctions]
type recordFunctions = {
p: unit => [@onUnit] recordFunctions,
q: [@onArrow] (unit => unit)
q: [@onArrow] (unit => unit),
}
[@onUnusedType]
and unusedType = unit;

[@onMyRecord]
let rec myRecord = {
p: () => myRecord,
q: () => ()
q: () => (),
}
[@onUnused]
and unused = ();
Expand All @@ -218,7 +219,7 @@ type variantType =
type gadtType('x) =
| Foo(int): [@onFirstRow] gadtType(int)
| Bar([@onInt] int): [@onSecondRow]
gadtType(unit)
gadtType(unit)
| Baz: [@onThirdRow] gadtType([@onUnit] unit);

[@floatingTopLevelStructureItem hello];
Expand Down Expand Up @@ -362,11 +363,13 @@ type xy =
let myFun =
(
[@onConstruction] X(hello) |
[@onConstruction] Y(hello)
[@onConstruction] Y(hello),
) => hello;

let myFun =
(X([@onHello] hello) | Y([@onHello] hello)) => hello;
(
X([@onHello] hello) | Y([@onHello] hello),
) => hello;

/* Another bug: Cannot have an attribute on or pattern
let myFun = fun ((X(hello) | Y(hello)) [@onOrPattern]) => hello;
Expand Down Expand Up @@ -402,9 +405,10 @@ type reconciler('props) = ..;
type reconciler('props) +=
| Foo(int): [@onFirstRow] reconciler(int)
| Bar([@onInt] int): [@onSecondRow]
reconciler(unit)
reconciler(unit)
| [@baz]
Baz: [@onThirdRow] reconciler([@onUnit] unit);
Baz: [@onThirdRow]
reconciler([@onUnit] unit);

type water = ..;

Expand Down
2 changes: 1 addition & 1 deletion formatTest/typeCheckedTests/expected_output/basics.re
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ let display =
(
~message=("hello": string),
~person: string="Reason",
time: float
time: float,
) => 1;
21 changes: 10 additions & 11 deletions formatTest/typeCheckedTests/expected_output/comments.re
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,18 @@ let testingNotQuiteEndOfLineComments = [
"Item 3" /* Comment For Third Item */,
"Item 4" /* Comment For Fourth Item - but no semi */
/* Comment after last item in list. */
] /* Comment after list bracket */;
]; /* Comment after list bracket */

let testingEndOfLineComments = [
"Item 1", /* Comment For First Item */
"Item 2", /* Comment For Second Item */
"Item 3", /* Comment For Third Item */
"Item 4" /* Comment For Fourth Item - but before semi */
"Item 4" /* Comment For Fourth Item - but before semi */,
/* Comment after last item in list. */
] /* Comment after list bracket */;
]; /* Comment after list bracket */

/* This time no space between bracket and comment */
let testingEndOfLineComments =
[] /* Comment after list bracket */;
let testingEndOfLineComments = []; /* Comment after list bracket */

type t = (int, int); /* End of line on t */

Expand All @@ -57,17 +56,17 @@ type variant =
/* Comment above X */
| X(int) /* End of line on X */
/* Comment above Y */
| Y(int) /* End of line on Y */;
| Y(int); /* End of line on Y */

/* Comment on entire type def for variant */
type x = {
/* not attached *above* x */
fieldOne: int
fieldOne: int,
} /* Attached end of line after x */
and y = {
/* not attached *above* y */
fieldTwo: int
} /* Attached end of line after y */;
fieldTwo: int,
}; /* Attached end of line after y */

let result =
switch (X(3)) {
Expand Down Expand Up @@ -113,10 +112,10 @@ type typeParamPointWithComments('a) = {
let name_equal = (x, y) => x == y;

let equal = (i1, i2) =>
i1.contents === i2.contents && true /* most unlikely first */;
i1.contents === i2.contents && true; /* most unlikely first */

let equal = (i1, i2) =>
compare(compare(0, 0), compare(1, 1)) /* END OF LINE HERE */;
compare(compare(0, 0), compare(1, 1)); /* END OF LINE HERE */

module Temp = {
let v = true;
Expand Down
Loading