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

ruby-changes:28072

From: nobu <ko1@a...>
Date: Fri, 5 Apr 2013 19:40:21 +0900 (JST)
Subject: [ruby-changes:28072] nobu:r40124 (trunk): compile.c: defined? with empty expression

nobu	2013-04-05 19:40:03 +0900 (Fri, 05 Apr 2013)

  New Revision: 40124

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

  Log:
    compile.c: defined? with empty expression
    
    * compile.c (iseq_compile_each): fix of defined? with empty
      expression.  [ruby-core:53999] [Bug #8220]

  Modified files:
    trunk/ChangeLog
    trunk/compile.c
    trunk/test/ruby/test_syntax.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40123)
+++ ChangeLog	(revision 40124)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Apr  5 19:39:52 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* compile.c (iseq_compile_each): fix of defined? with empty
+	  expression.  [ruby-core:53999] [Bug #8220]
+
 Fri Apr  5 13:22:59 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/curses/curses.c (Init_curses): fix implementation function,
Index: compile.c
===================================================================
--- compile.c	(revision 40123)
+++ compile.c	(revision 40124)
@@ -5175,7 +5175,12 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L5175
 	break;
       }
       case NODE_DEFINED:{
-	if (!poped) {
+	if (poped) break;
+	if (!node->nd_head) {
+	    VALUE str = rb_iseq_defined_string(DEFINED_NIL);
+	    ADD_INSN1(ret, nd_line(node), putobject, str);
+	}
+	else {
 	    LABEL *lfinish[2];
 	    lfinish[0] = NEW_LABEL(line);
 	    lfinish[1] = 0;
Index: test/ruby/test_syntax.rb
===================================================================
--- test/ruby/test_syntax.rb	(revision 40123)
+++ test/ruby/test_syntax.rb	(revision 40124)
@@ -13,6 +13,11 @@ class TestSyntax < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L13
     eom
   end
 
+  def test_defined_empty_argument
+    bug8220 = '[ruby-core:53999] [Bug #8220]'
+    assert_ruby_status(%w[--disable-gem], 'puts defined? ()', bug8220)
+  end
+
   def test_must_ascii_compatible
     require 'tempfile'
     f = Tempfile.new("must_ac_")

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

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