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

ruby-changes:22989

From: nobu <ko1@a...>
Date: Thu, 15 Mar 2012 15:38:00 +0900 (JST)
Subject: [ruby-changes:22989] nobu:r35038 (trunk): * parse.y (parser_yylex): fix warning line number.

nobu	2012-03-15 15:37:46 +0900 (Thu, 15 Mar 2012)

  New Revision: 35038

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35038

  Log:
    * parse.y (parser_yylex): fix warning line number.

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
    trunk/test/ruby/test_syntax.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 35037)
+++ ChangeLog	(revision 35038)
@@ -1,3 +1,7 @@
+Thu Mar 15 15:37:42 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (parser_yylex): fix warning line number.
+
 Thu Mar 15 15:19:38 2012  Nobuyoshi Nakada  <nobu@r...>
 
 	* enumerator.c (lazy_cycle): check argument number overflow before
Index: parse.y
===================================================================
--- parse.y	(revision 35037)
+++ parse.y	(revision 35038)
@@ -2694,7 +2694,6 @@
 		    }
 		| tLPAREN_ARG expr {lex_state = EXPR_ENDARG;} rparen
 		    {
-			rb_warning0("(...) interpreted as grouped expression");
 		    /*%%%*/
 			$$ = $2;
 		    /*%
@@ -7617,6 +7616,7 @@
 	}
 	else if (IS_SPCARG(-1)) {
 	    c = tLPAREN_ARG;
+	    rb_warning0("(...) interpreted as grouped expression");
 	}
 	paren_nest++;
 	COND_PUSH(0);
Index: test/ruby/test_syntax.rb
===================================================================
--- test/ruby/test_syntax.rb	(revision 35037)
+++ test/ruby/test_syntax.rb	(revision 35038)
@@ -1,4 +1,5 @@
 require 'test/unit'
+require_relative 'envutil'
 
 class TestSyntax < Test::Unit::TestCase
   def assert_valid_syntax(code, fname, mesg = fname)
@@ -8,6 +9,7 @@
     }
     code.force_encoding("us-ascii")
     verbose, $VERBOSE = $VERBOSE, nil
+    yield if defined?(yield)
     assert_nothing_raised(SyntaxError, mesg) do
       assert_equal(:ok, catch {|tag| eval(code, binding, fname, 0)}, mesg)
     end
@@ -88,6 +90,12 @@
     assert_equal({foo: 1, bar: 2}, o.kw(foo: 1, bar: 2))
   end
 
+  def test_warn_grouped_expression
+    assert_warn("test:2: warning: (...) interpreted as grouped expression\n") do
+      assert_valid_syntax("foo \\\n(\n  true)", "test") {$VERBOSE = true}
+    end
+  end
+
   private
 
   def make_tmpsrc(f, src)

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

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