Skip to content

Commit

Permalink
Remove extra space before return type declaration in function definit…
Browse files Browse the repository at this point in the history
…ion (#1966)

* Remove extra space before return type declaration in function definition

fixes #1628

* remove indent setting, not needed
  • Loading branch information
anmonteiro authored and chenglou committed May 28, 2018
1 parent 46c8930 commit 1a10d3c
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 24 deletions.
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
7 changes: 5 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,10 @@ 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
~inline:(true, true)
(argsList@[formatJustTheTypeConstraint typeLayout])], e)
| _ -> (argsList, return)
method normalizeConstructorArgsConstraint argsList return =
Expand Down

0 comments on commit 1a10d3c

Please sign in to comment.