forked from sorbet/sorbet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Ruby 3.0] Add support for endless method definitions (sorbet#4359)
* Import endless method definition tests Co-authored-by: Alexandre Terrasa <583144+Morriar@users.noreply.github.com> * [Ruby 3.0] Add support for endless method definitions Co-authored-by: Alexandre Terrasa <583144+Morriar@users.noreply.github.com> * Remove overload parse error that no longer occures with endless method support Co-authored-by: Alexandre Terrasa <583144+Morriar@users.noreply.github.com> Co-authored-by: Alexandre Terrasa <583144+Morriar@users.noreply.github.com>
- Loading branch information
Showing
44 changed files
with
311 additions
and
43 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
4 changes: 4 additions & 0 deletions
4
test/whitequark/test_endless_comparison_method_0.parse-tree-whitequark.exp
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(:def, :===, | ||
s(:args, | ||
s(:arg, :other)), | ||
s(:send, nil, :do_something)) |
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 ===(other) = do_something |
4 changes: 4 additions & 0 deletions
4
test/whitequark/test_endless_comparison_method_1.parse-tree-whitequark.exp
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(:def, :==, | ||
s(:args, | ||
s(:arg, :other)), | ||
s(:send, nil, :do_something)) |
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 ==(other) = do_something |
4 changes: 4 additions & 0 deletions
4
test/whitequark/test_endless_comparison_method_2.parse-tree-whitequark.exp
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(:def, :!=, | ||
s(:args, | ||
s(:arg, :other)), | ||
s(:send, nil, :do_something)) |
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 !=(other) = do_something |
4 changes: 4 additions & 0 deletions
4
test/whitequark/test_endless_comparison_method_3.parse-tree-whitequark.exp
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(:def, :<=, | ||
s(:args, | ||
s(:arg, :other)), | ||
s(:send, nil, :do_something)) |
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 <=(other) = do_something |
4 changes: 4 additions & 0 deletions
4
test/whitequark/test_endless_comparison_method_4.parse-tree-whitequark.exp
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(:def, :>=, | ||
s(:args, | ||
s(:arg, :other)), | ||
s(:send, nil, :do_something)) |
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 >=(other) = do_something |
4 changes: 4 additions & 0 deletions
4
test/whitequark/test_endless_comparison_method_5.parse-tree-whitequark.exp
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(:def, :!=, | ||
s(:args, | ||
s(:arg, :other)), | ||
s(:send, nil, :do_something)) |
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 !=(other) = do_something |
3 changes: 3 additions & 0 deletions
3
test/whitequark/test_endless_method_0.parse-tree-whitequark.exp
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, :foo, | ||
s(:args), | ||
s(:int, "42")) |
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 foo() = 42 |
6 changes: 6 additions & 0 deletions
6
test/whitequark/test_endless_method_1.parse-tree-whitequark.exp
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,6 @@ | ||
s(:def, :inc, | ||
s(:args, | ||
s(:arg, :x)), | ||
s(:send, | ||
s(:lvar, :x), :+, | ||
s(:int, "1"))) |
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 inc(x) = x + 1 |
4 changes: 4 additions & 0 deletions
4
test/whitequark/test_endless_method_2.parse-tree-whitequark.exp
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(:defs, | ||
s(:send, nil, :obj), :foo, | ||
s(:args), | ||
s(:int, "42")) |
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 obj.foo() = 42 |
7 changes: 7 additions & 0 deletions
7
test/whitequark/test_endless_method_3.parse-tree-whitequark.exp
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 @@ | ||
s(:defs, | ||
s(:send, nil, :obj), :inc, | ||
s(:args, | ||
s(:arg, :x)), | ||
s(:send, | ||
s(:lvar, :x), :+, | ||
s(:int, "1"))) |
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 obj.inc(x) = x + 1 |
5 changes: 5 additions & 0 deletions
5
test/whitequark/test_endless_method_forwarded_args_legacy_0.parse-tree-whitequark.exp
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(:def, :foo, | ||
s(:args, | ||
s(:forward_arg)), | ||
s(:send, nil, :bar, | ||
s(:forwarded_args))) |
3 changes: 3 additions & 0 deletions
3
test/whitequark/test_endless_method_forwarded_args_legacy_0.rb
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 foo(...) = bar(...) |
6 changes: 6 additions & 0 deletions
6
test/whitequark/test_endless_method_with_rescue_mod_0.parse-tree-whitequark.exp
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,6 @@ | ||
s(:def, :m, | ||
s(:args), | ||
s(:rescue, | ||
s(:int, "1"), | ||
s(:resbody, nil, nil, | ||
s(:int, "2")), 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 m() = 1 rescue 2 |
7 changes: 7 additions & 0 deletions
7
test/whitequark/test_endless_method_with_rescue_mod_1.parse-tree-whitequark.exp
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 @@ | ||
s(:defs, | ||
s(:self), :m, | ||
s(:args), | ||
s(:rescue, | ||
s(:int, "1"), | ||
s(:resbody, nil, nil, | ||
s(:int, "2")), 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 self.m() = 1 rescue 2 |
2 changes: 2 additions & 0 deletions
2
test/whitequark/test_endless_method_without_args_0.parse-tree-whitequark.exp
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,2 @@ | ||
s(:def, :foo, nil, | ||
s(:int, "42")) |
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 foo = 42 |
5 changes: 5 additions & 0 deletions
5
test/whitequark/test_endless_method_without_args_1.parse-tree-whitequark.exp
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(:def, :foo, nil, | ||
s(:rescue, | ||
s(:int, "42"), | ||
s(:resbody, nil, nil, | ||
s(:nil)), 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 foo = 42 rescue nil |
3 changes: 3 additions & 0 deletions
3
test/whitequark/test_endless_method_without_args_2.parse-tree-whitequark.exp
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(:defs, | ||
s(:self), :foo, nil, | ||
s(:int, "42")) |
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 self.foo = 42 |
6 changes: 6 additions & 0 deletions
6
test/whitequark/test_endless_method_without_args_3.parse-tree-whitequark.exp
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,6 @@ | ||
s(:defs, | ||
s(:self), :foo, nil, | ||
s(:rescue, | ||
s(:int, "42"), | ||
s(:resbody, nil, nil, | ||
s(:nil)), 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 self.foo = 42 rescue 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 foo=() = 42 # error: setter method cannot be defined in an endless method definition |
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 obj.foo=() = 42 # error: setter method cannot be defined in an endless method definition |
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 foo=() = 42 rescue nil # error: setter method cannot be defined in an endless method definition |
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 obj.foo=() = 42 rescue nil # error: setter method cannot be defined in an endless method definition |
Oops, something went wrong.