-
Notifications
You must be signed in to change notification settings - Fork 509
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support parsing for **nil args (#3412)
* ruby27: Parse `**nil` arguments This commit tracks upstream commit ruby/ruby@6a9ce1f. Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com> * Skip **nil args when desugaring Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
- Loading branch information
Showing
14 changed files
with
196 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
Begin { | ||
stmts = [ | ||
DefMethod { | ||
name = <U f1> | ||
args = Args { | ||
args = [ | ||
Kwnilarg { | ||
} | ||
] | ||
} | ||
body = NULL | ||
} | ||
DefMethod { | ||
name = <U f2> | ||
args = Args { | ||
args = [ | ||
Restarg { | ||
name = <U args> | ||
} | ||
Kwnilarg { | ||
} | ||
] | ||
} | ||
body = NULL | ||
} | ||
DefMethod { | ||
name = <U f3> | ||
args = Args { | ||
args = [ | ||
Arg { | ||
name = <U a> | ||
} | ||
Arg { | ||
name = <U b> | ||
} | ||
Arg { | ||
name = <U c> | ||
} | ||
Kwnilarg { | ||
} | ||
] | ||
} | ||
body = NULL | ||
} | ||
DefMethod { | ||
name = <U f4> | ||
args = Args { | ||
args = [ | ||
Arg { | ||
name = <U a> | ||
} | ||
Arg { | ||
name = <U b> | ||
} | ||
Restarg { | ||
name = <U c> | ||
} | ||
Kwnilarg { | ||
} | ||
] | ||
} | ||
body = NULL | ||
} | ||
DefMethod { | ||
name = <U f5> | ||
args = Args { | ||
args = [ | ||
Kwnilarg { | ||
} | ||
Blockarg { | ||
name = <U blk> | ||
} | ||
] | ||
} | ||
body = NULL | ||
} | ||
DefMethod { | ||
name = <U f6> | ||
args = Args { | ||
args = [ | ||
Arg { | ||
name = <U a> | ||
} | ||
Arg { | ||
name = <U b> | ||
} | ||
Arg { | ||
name = <U c> | ||
} | ||
Kwnilarg { | ||
} | ||
Blockarg { | ||
name = <U blk> | ||
} | ||
] | ||
} | ||
body = NULL | ||
} | ||
DefMethod { | ||
name = <U f7> | ||
args = Args { | ||
args = [ | ||
Arg { | ||
name = <U a> | ||
} | ||
Arg { | ||
name = <U b> | ||
} | ||
Restarg { | ||
name = <U c> | ||
} | ||
Kwnilarg { | ||
} | ||
Blockarg { | ||
name = <U blk> | ||
} | ||
] | ||
} | ||
body = NULL | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# typed: true | ||
|
||
def f1(**nil); end | ||
def f2(*args, **nil); end | ||
def f3(a, b, c, **nil); end | ||
def f4(a, b, *c, **nil); end | ||
def f5(**nil, &blk); end | ||
def f6(a, b, c, **nil, &blk); end | ||
def f7(a, b, *c, **nil, &blk); end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# typed: true | ||
|
||
def f1(**nil, **nil); end # error: unexpected token "**" | ||
def f2(*args, **kwargs, **nil); end # error: unexpected token "**" | ||
def f3(*args, a:, **nil); end # error: unexpected token "nil" | ||
def f4(a:, **nil); end # error: unexpected token "nil" | ||
def f5(**nil: 10); end # error: unexpected token tLABEL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
s(:def, :f, | ||
s(:args, | ||
s(:kwnilarg)), nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# typed: true | ||
|
||
def f(**nil); end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
s(:block, | ||
s(:send, nil, :m), | ||
s(:args, | ||
s(:kwnilarg)), nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# typed: true | ||
|
||
m { |**nil| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
s(:block, | ||
s(:send, | ||
s(:const, nil, :Kernel), :lambda), | ||
s(:args, | ||
s(:kwnilarg)), nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# typed: true | ||
|
||
->(**nil) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters