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

ruby-changes:48024

From: nobu <ko1@a...>
Date: Sun, 8 Oct 2017 15:01:03 +0900 (JST)
Subject: [ruby-changes:48024] nobu:r60138 (trunk): parse.y: fix a typo

nobu	2017-10-08 15:00:57 +0900 (Sun, 08 Oct 2017)

  New Revision: 60138

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60138

  Log:
    parse.y: fix a typo
    
    * parse.y (f_kw): fix typo.  needs the argument value, not the
      label twice.  [ruby-core:83174] [Bug #13987]

  Modified files:
    trunk/parse.y
    trunk/test/ripper/test_sexp.rb
Index: test/ripper/test_sexp.rb
===================================================================
--- test/ripper/test_sexp.rb	(revision 60137)
+++ test/ripper/test_sexp.rb	(revision 60138)
@@ -96,6 +96,20 @@ eot https://github.com/ruby/ruby/blob/trunk/test/ripper/test_sexp.rb#L96
     assert_equal("t", fname)
   end
 
+  def test_named_with_default
+    sexp = Ripper.sexp("def hello(bln: true, int: 1, str: 'str', sym: :sym) end")
+    named = String.new
+    search_sexp(:params, sexp)[5].each { |i| named << "#{i}\n" }  # join flattens
+    exp = "#{<<-"{#"}#{<<~'};'}"
+    {#
+      [[:@label, "bln:", [1, 10]], [:var_ref, [:@kw, "true", [1, 15]]]]
+      [[:@label, "int:", [1, 21]], [:@int, "1", [1, 26]]]
+      [[:@label, "str:", [1, 29]], [:string_literal, [:string_content, [:@tstring_content, "str", [1, 35]]]]]
+      [[:@label, "sym:", [1, 41]], [:symbol_literal, [:symbol, [:@ident, "sym", [1, 47]]]]]
+    };
+    assert_equal(exp, named)
+  end
+
   def search_sexp(sym, sexp)
     return sexp if !sexp or sexp[0] == sym
     sexp.find do |e|
Index: parse.y
===================================================================
--- parse.y	(revision 60137)
+++ parse.y	(revision 60138)
@@ -4408,7 +4408,7 @@ f_kw		: f_label arg_value https://github.com/ruby/ruby/blob/trunk/parse.y#L4408
 		    /*%%%*/
 			$$ = new_kw_arg($$);
 		    /*%
-			$$ = rb_assoc_new(get_value($$), get_value($1));
+			$$ = rb_assoc_new(get_value($$), get_value($2));
 		    %*/
 		    }
 		| f_label

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

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