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

Remove extra space before return type declaration in function definition #1966

Merged
merged 2 commits into from
May 28, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions formatTest/typeCheckedTests/expected_output/basics.re
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ let argIsUnderscore1 = _ => 34;

let argIsUnderscore2 = _ => 34;

let argIsUnderscore3 = _ : int => 34;
let argIsUnderscore3 = _: int => 34;

let argIsUnderscore4 = _ : int => 34;
let argIsUnderscore4 = _: int => 34;

let argIsUnderscore5 = (_: int) => 34;

Expand Down
4 changes: 2 additions & 2 deletions formatTest/typeCheckedTests/expected_output/basics_no_semi.re
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ let argIsUnderscore1 = _ => 34;

let argIsUnderscore2 = _ => 34;

let argIsUnderscore3 = _ : int => 34;
let argIsUnderscore3 = _: int => 34;

let argIsUnderscore4 = _ : int => 34;
let argIsUnderscore4 = _: int => 34;

let argIsUnderscore5 = (_: int) => 34;

Expand Down
9 changes: 3 additions & 6 deletions formatTest/unit_tests/expected_output/basicStructures.re
Original file line number Diff line number Diff line change
Expand Up @@ -532,20 +532,17 @@ let addValues = (a: int, b: int) => a + b;

let addValues = (a: int, b: int) => a + b;

let myFunction = (a: int, b: int) : int =>
a + b;
let myFunction = (a: int, b: int): int => a + b;

let functionReturnValueType =
(i: int, s: string)
: (int => int) =>
(i: int, s: string): (int => int) =>
x => x + 1;

let curriedFormOne = (i: int, s: string) =>
s ++ string_of_int(i);

let curriedFormTwo =
(i: int, x: int)
: (int, int) => (
(i: int, x: int): (int, int) => (
i,
x,
);
Expand Down
2 changes: 1 addition & 1 deletion formatTest/unit_tests/expected_output/modules.re
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ module Example2 = (F: (Type) => Type, X: Type) => {
* let iso (a:(Compose Id F X).t): (F X).t => a;
*
*/
let iso = (a: Compose(Id)(F)(X).t) : F(X).t => a;
let iso = (a: Compose(Id)(F)(X).t): F(X).t => a;
};

Printf.printf(
Expand Down
2 changes: 1 addition & 1 deletion formatTest/unit_tests/expected_output/modules_no_semi.re
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ module Example2 = (F: (Type) => Type, X: Type) => {
* let iso (a:(Compose Id F X).t): (F X).t => a
*
*/
let iso = (a: Compose(Id)(F)(X).t) : F(X).t => a;
let iso = (a: Compose(Id)(F)(X).t): F(X).t => a;
};

Printf.printf(
Expand Down
3 changes: 1 addition & 2 deletions formatTest/unit_tests/expected_output/polymorphism.re
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ type myType2 =
/* Confusing because => looks like part
of the return type signature. */
let myFunc =
(a: int => int, b: int => int)
: myType(int) => [
(a: int => int, b: int => int): myType(int) => [
a(20) + b(30),
];

Expand Down
12 changes: 5 additions & 7 deletions formatTest/unit_tests/expected_output/syntax.re
Original file line number Diff line number Diff line change
Expand Up @@ -611,9 +611,7 @@ let tupleInsideALetSequence = {

/* We *require* that function return types be wrapped in
parenthesis. In this example, there's no ambiguity */
let makeIncrementer =
(delta: int)
: (int => int) =>
let makeIncrementer = (delta: int): (int => int) =>
a => a + delta;

/* We could even force that consistency with let bindings - it's allowed
Expand All @@ -635,18 +633,18 @@ class classWithNoArg = {
end;
*/

let myFunc = (a: int, b: int) : (int, int) => (
let myFunc = (a: int, b: int): (int, int) => (
a,
b,
);
let myFunc = (a: int, b: int) : list(int) => [
let myFunc = (a: int, b: int): list(int) => [
1,
];
let myFunc = (a: int, b: int) : point => {
let myFunc = (a: int, b: int): point => {
x: a,
y: b,
};
let myFunc = (a: int, b: int) : point => {
let myFunc = (a: int, b: int): point => {
x: a,
y: b,
};
Expand Down
2 changes: 1 addition & 1 deletion src/reason-parser/reason_layout.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type separator =
| SepFinal of string * string

(**
* Module concerning info to correctly interleave whitspace above a layout node.
* Module concerning info to correctly interleave whitespace above a layout node.
*)
module WhitespaceRegion = struct
type t = {
Expand Down
8 changes: 6 additions & 2 deletions src/reason-parser/reason_pprint_ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1989,7 +1989,7 @@ let is_punned_labelled_expression e lbl = match e.pexp_desc with
| _ -> false

let is_punned_labelled_pattern p lbl = match p.ppat_desc with
| Ppat_constraint ({ ppat_desc = Ppat_var { txt; _ }; ppat_attributes = _::_ }, _)
| Ppat_constraint ({ ppat_desc = Ppat_var { txt; _ }; ppat_attributes = _::_ }, _)
-> false
| Ppat_constraint ({ ppat_desc = Ppat_var { txt; _ }; _ }, _)
| Ppat_var { txt; _ }
Expand Down Expand Up @@ -4675,7 +4675,11 @@ let printer = object(self:'self)
source_map ~loc:ct.ptyp_loc
(self#non_arrowed_non_simple_core_type ct)
in
(argsList@[formatJustTheTypeConstraint typeLayout], e)
([makeList
~break:IfNeed
~indent:(settings.space * settings.indentWrappedPatternArgs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh man, settings.space? Have we been using this consistently? cc @IwanKaramazow

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the same setting that wrapCurriedFunctionBinding employs, given that's where it all trickled down before.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

settings.space exists and the space setting is used only in function bindings I think. It's pretty obscure, since it defaults to the default 2 here.

~inline:(true, true)
(argsList@[formatJustTheTypeConstraint typeLayout])], e)
| _ -> (argsList, return)

method normalizeConstructorArgsConstraint argsList return =
Expand Down