diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-05-18 16:26:36 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-05-18 16:26:36 +0900 |
| commit | 07c847027875a955ba64d3c84f8f456e96155b31 (patch) | |
| tree | 6495026956e7e00d54ada56b1467883ac07960df /test/t/syntax.rb | |
| parent | d50c83cca72f5686292427f5b6606482fd3ad380 (diff) | |
| download | mruby-07c847027875a955ba64d3c84f8f456e96155b31.tar.gz mruby-07c847027875a955ba64d3c84f8f456e96155b31.zip | |
parse.y: allow "command" syntax in endless method definition.
This change allows `def hello = puts "Hello"` without parentheses.
This syntax has been introduced since Ruby3.1.
Diffstat (limited to 'test/t/syntax.rb')
| -rw-r--r-- | test/t/syntax.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/t/syntax.rb b/test/t/syntax.rb index b3ee2d438..3d4d230eb 100644 --- a/test/t/syntax.rb +++ b/test/t/syntax.rb @@ -706,3 +706,20 @@ assert('argument forwarding') do o.a(1,2,3){} o.b(1,2,3){} end + +assert('endless def') do + Class.new do + def m1 = 42 + def m2() = 42 + def m3(x) = x+1 + def self.s1 = 42 + def self.s2() = 42 + def self.s3(x) = x + 1 + def c1 = 42 + def cm2() = p 42 + def cm3(x) = p x+1 + def self.cs1 = p 42 + def self.cs2() = p 42 + def self.cs3(x) = p x + 1 + end +end |
