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

ruby-changes:47837

From: nobu <ko1@a...>
Date: Tue, 19 Sep 2017 09:23:04 +0900 (JST)
Subject: [ruby-changes:47837] nobu:r59957 (trunk): parse.y: lex by lvar

nobu	2017-09-19 09:22:56 +0900 (Tue, 19 Sep 2017)

  New Revision: 59957

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

  Log:
    parse.y: lex by lvar
    
    * parse.y (parse_ident): disable tLPAREN_ARG state by local
      variable.  [ruby-list:50578]

  Modified files:
    trunk/parse.y
    trunk/test/ruby/test_parse.rb
Index: test/ruby/test_parse.rb
===================================================================
--- test/ruby/test_parse.rb	(revision 59956)
+++ test/ruby/test_parse.rb	(revision 59957)
@@ -1054,6 +1054,17 @@ x = __ENCODING__ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L1054
     assert_not_match(/unexpected tSTRING_END/, e)
   end
 
+  def test_lparenarg
+    o = Struct.new(:x).new
+    def o.i(x)
+      self.x = x
+    end
+    o.instance_eval {i (-1.3).abs}
+    assert_equal(1.3, o.x)
+    o.instance_eval {i = 0; i (-1.3).abs}
+    assert_equal(1.3, o.x)
+  end
+
 =begin
   def test_past_scope_variable
     assert_warning(/past scope/) {catch {|tag| eval("BEGIN{throw tag}; tap {a = 1}; a")}}
Index: parse.y
===================================================================
--- parse.y	(revision 59956)
+++ parse.y	(revision 59957)
@@ -8468,7 +8468,7 @@ parser_yylex(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/parse.y#L8468
 			"an argument list, not a decomposed argument");
 	}
 	else if (lex_state == (EXPR_END|EXPR_LABEL) && space_seen) {
-	    rb_warning0("don't put space before argument parentheses");
+	    c = tLPAREN_ARG;
 	}
 	paren_nest++;
 	COND_PUSH(0);

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

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