[前][次][番号順一覧][スレッド一覧]

ruby-changes:63688

From: Nobuhiro <ko1@a...>
Date: Sun, 22 Nov 2020 21:00:30 +0900 (JST)
Subject: [ruby-changes:63688] 5218f17737 (master): [ruby/irb] support more body argument for oneliner method definition

https://git.ruby-lang.org/ruby.git/commit/?id=5218f17737

From 5218f17737594867ffe5c2cd9c90b19c7378af05 Mon Sep 17 00:00:00 2001
From: Nobuhiro IMAI <nov@y...>
Date: Tue, 22 Sep 2020 09:06:43 +0900
Subject: [ruby/irb] support more body argument for oneliner method definition

https://github.com/ruby/irb/commit/2ff1295533

diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb
index 7be77fd..c75d5eb 100644
--- a/lib/irb/ruby-lex.rb
+++ b/lib/irb/ruby-lex.rb
@@ -317,14 +317,12 @@ class RubyLex https://github.com/ruby/ruby/blob/trunk/lib/irb/ruby-lex.rb#L317
           if t[2] == '='
             in_oneliner_def = :BODY
           end
-        elsif t[3].allbits?(Ripper::EXPR_END)
+        else
           if in_oneliner_def == :BODY
             # one-liner method definition
             indent -= 1
           end
           in_oneliner_def = nil
-        else
-          in_oneliner_def = nil
         end
       end
 
@@ -376,14 +374,12 @@ class RubyLex https://github.com/ruby/ruby/blob/trunk/lib/irb/ruby-lex.rb#L374
           if t[2] == '='
             in_oneliner_def = :BODY
           end
-        elsif t[3].allbits?(Ripper::EXPR_END)
+        else
           if in_oneliner_def == :BODY
             # one[-liner method definition
             depth_difference -= 1
           end
           in_oneliner_def = nil
-        else
-          in_oneliner_def = nil
         end
       end
 
@@ -451,7 +447,7 @@ class RubyLex https://github.com/ruby/ruby/blob/trunk/lib/irb/ruby-lex.rb#L447
           if t[2] == '='
             in_oneliner_def = :BODY
           end
-        elsif t[3].allbits?(Ripper::EXPR_END)
+        else
           if in_oneliner_def == :BODY
             # one-liner method definition
             if is_first_printable_of_line
@@ -462,8 +458,6 @@ class RubyLex https://github.com/ruby/ruby/blob/trunk/lib/irb/ruby-lex.rb#L458
             end
           end
           in_oneliner_def = nil
-        else
-          in_oneliner_def = nil
         end
       end
 
diff --git a/test/irb/test_ruby_lex.rb b/test/irb/test_ruby_lex.rb
index 14b43f5..25f037e 100644
--- a/test/irb/test_ruby_lex.rb
+++ b/test/irb/test_ruby_lex.rb
@@ -233,6 +233,8 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_ruby_lex.rb#L233
         Row.new(%q(  def bar0() = 3), nil, 2),
         Row.new(%q(  def bar1(a) = a), nil, 2),
         Row.new(%q(  def bar2(a, b) = a + b), nil, 2),
+        Row.new(%q(  def bar3() = :s), nil, 2),
+        Row.new(%q(  def bar4() = Time.now), nil, 2),
         Row.new(%q(end), 0, 0),
       ]
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]