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

Alternative syntax for method calls - changes foo#bar to foo..bar. #580

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion formatTest/typeCheckedTests/expected_output/attributes.re
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ add 2 4 [@appliesToEntireFunctionApplication];
let myObj = {method p () => {method z () => 10}};

let result =
(myObj#p () [@attOnFirstSend])#z
(myObj..p () [@attOnFirstSend])..z
() [@onSecondSend];

type recordFunctions = {
Expand Down
10 changes: 5 additions & 5 deletions formatTest/typeCheckedTests/expected_output/oo.re
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ let coercedReturn = {
};

let acceptsOpenAnonObjAsArg
(o: <x : int, y : int, ..>) => o#x + o#y;
(o: <x : int, y : int, ..>) => o..x + o..y;

let acceptsClosedAnonObjAsArg
(o: <x : int, y : int>) => o#x + o#y;
(o: <x : int, y : int>) => o..x + o..y;

let res = acceptsOpenAnonObjAsArg {
method x = 0;
Expand Down Expand Up @@ -304,7 +304,7 @@ let incrementMyClassInstance:
#tupleClass int int =>
#tupleClass int int =
fun i inst => {
let (x, y) = inst#pr;
let (x, y) = inst..pr;
{method pr = (x + i, y + i)}
};

Expand Down Expand Up @@ -350,7 +350,7 @@ class addablePoint:
method add
(one: addablePointClassType)
(two: addablePointClassType) =>
one#x + two#x + one#y + two#x;
one..x + two..x + one..y + two..x;
method x: int = init;
method y = init;
};
Expand All @@ -362,7 +362,7 @@ class addablePoint2:
method add
(one: addablePointClassType)
(two: addablePointClassType) =>
one#x + two#x + one#y + two#x;
one..x + two..x + one..y + two..x;
method x: int = init;
method y = init;
};
Expand Down
2 changes: 1 addition & 1 deletion formatTest/typeCheckedTests/input/attributes.re
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ let myObj = {
};
};

let result = (myObj#p () [@attOnFirstSend])#z () [@onSecondSend];
let result = (myObj..p () [@attOnFirstSend])..z () [@onSecondSend];

type recordFunctions = {
p: unit => recordFunctions [@onUnit],
Expand Down
10 changes: 5 additions & 5 deletions formatTest/typeCheckedTests/input/oo.re
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ let coercedReturn = {
(tmp :> <x: int>)
};

let acceptsOpenAnonObjAsArg (o: <x: int, y:int, ..>) => o#x + o#y;
let acceptsClosedAnonObjAsArg (o: <x: int, y:int>) => o#x + o#y;
let acceptsOpenAnonObjAsArg (o: <x: int, y:int, ..>) => o..x + o..y;
let acceptsClosedAnonObjAsArg (o: <x: int, y:int>) => o..x + o..y;
let res = acceptsOpenAnonObjAsArg {
method x => 0;
method y => 10;
Expand Down Expand Up @@ -252,7 +252,7 @@ let x: #tupleClass int int = x;

let incrementMyClassInstance: int => #tupleClass int int => #tupleClass int int =
fun i inst => {
let (x, y) = inst#pr;
let (x, y) = inst..pr;
{method pr => (x + i, y + i);};
};

Expand Down Expand Up @@ -288,15 +288,15 @@ class type addablePointClassType = {
class addablePoint: int => new addablePointClassType = fun init => {
as self;
method add (one: addablePointClassType) (two:addablePointClassType) =>
one#x + two#x + one#y + two#x;
one..x + two..x + one..y + two..x;
method x => (init : int);
method y => init;
};

class addablePoint2 = (fun init => {
as self;
method add (one: addablePointClassType) (two:addablePointClassType) =>
one#x + two#x + one#y + two#x;
one..x + two..x + one..y + two..x;
method x => (init : int);
method y => init;
} : int => new addablePointClassType);
Expand Down
16 changes: 8 additions & 8 deletions formatTest/unit_tests/expected_output/basicStructures.re
Original file line number Diff line number Diff line change
Expand Up @@ -31,39 +31,39 @@ for i in

let x = !foo.bar;

let x = !foo#bar;
let x = !foo..bar;

let x = !(!foo).bar;

let x = !(!foo)#bar;
let x = !(!foo)..bar;

/* Prefix operator */
let x = !!foo.bar;

let x = !!foo#bar;
let x = !!foo..bar;

let x = !~foo.bar;

let x = !~foo#bar;
let x = !~foo..bar;

let noParensNeeded = !blah.foo.bar;

let parensNeededAroundFirst = (!blah).foo.bar;

let parensNeededAroundSecond = (!blah.foo).bar;

let noParensNeeded = !blah#foo#bar;
let noParensNeeded = !blah..foo..bar;

let parensNeededAroundFirst = (!blah)#foo#bar;
let parensNeededAroundFirst = (!blah)..foo..bar;

let parensNeededAroundSecond = (!blah#foo)#bar;
let parensNeededAroundSecond = (!blah..foo)..bar;

/* The following two have an error in formatting! We must check for
* *consecutive* prefix operators and either space separate or guard in
* parens. */
let x = !!foo.bar;

let x = !!foo#bar;
let x = !!foo..bar;

/* Comments */
/*Below is an empty comment*/
Expand Down
16 changes: 8 additions & 8 deletions formatTest/unit_tests/input/basicStructures.re
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,39 @@ for i in 0 to (endOfRangeMustBeSimple expr soWrap) {

let x = !foo.bar;

let x = !foo#bar;
let x = !foo..bar;

let x = !(!foo).bar;

let x = !(!foo)#bar;
let x = !(!foo)..bar;

/* Prefix operator */
let x = !!foo.bar;

let x = !!foo#bar;
let x = !!foo..bar;

let x = !~foo.bar;

let x = !~foo#bar;
let x = !~foo..bar;

let noParensNeeded = !blah.foo.bar;

let parensNeededAroundFirst = (!blah).foo.bar;

let parensNeededAroundSecond = (!blah.foo).bar;

let noParensNeeded = !blah#foo#bar;
let noParensNeeded = !blah..foo..bar;

let parensNeededAroundFirst = (!blah)#foo#bar;
let parensNeededAroundFirst = (!blah)..foo..bar;

let parensNeededAroundSecond = (!blah#foo)#bar;
let parensNeededAroundSecond = (!blah..foo)..bar;

/* The following two have an error in formatting! We must check for
* *consecutive* prefix operators and either space separate or guard in
* parens. */
let x = !(!foo.bar);

let x = !(!foo#bar);
let x = !(!foo..bar);


/* Comments */
Expand Down
Loading