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

ruby-changes:24976

From: naruse <ko1@a...>
Date: Tue, 25 Sep 2012 08:22:18 +0900 (JST)
Subject: [ruby-changes:24976] naruse:r37027 (trunk): * iseq.c (rb_iseq_defined_string): the index of defined_strings must

naruse	2012-09-25 08:17:59 +0900 (Tue, 25 Sep 2012)

  New Revision: 37027

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

  Log:
    * iseq.c (rb_iseq_defined_string): the index of defined_strings must
      be the value of type - 1.

  Modified files:
    trunk/ChangeLog
    trunk/iseq.c
    trunk/test/ruby/test_defined.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 37026)
+++ ChangeLog	(revision 37027)
@@ -1,3 +1,8 @@
+Tue Sep 25 08:11:11 2012  NARUSE, Yui  <naruse@r...>
+
+	* iseq.c (rb_iseq_defined_string): the index of defined_strings must
+	  be the value of type - 1.
+
 Mon Sep 24 17:36:51 2012  Nobuyoshi Nakada  <nobu@r...>
 
 	* compile.c (defined_expr), insns.def (defined): share single frozen
Index: iseq.c
===================================================================
--- iseq.c	(revision 37026)
+++ iseq.c	(revision 37027)
@@ -1779,11 +1779,11 @@
 	defs = ruby_xcalloc(numberof(expr_names), sizeof(VALUE));
 	GET_VM()->defined_strings = defs;
     }
-    str = defs[type];
+    str = defs[type-1];
     if (!str) {
 	str = rb_str_new_cstr(estr);;
 	OBJ_FREEZE(str);
-	defs[type] = str;
+	defs[type-1] = str;
     }
     return str;
 }
Index: test/ruby/test_defined.rb
===================================================================
--- test/ruby/test_defined.rb	(revision 37026)
+++ test/ruby/test_defined.rb	(revision 37027)
@@ -84,6 +84,11 @@
     assert_equal 'global-variable', defined?($+)
     assert_equal 'global-variable', defined?($1)
     assert_equal nil, defined?($2)
+
+    assert_equal("nil", defined?(nil))
+    assert_equal("true", defined?(true))
+    assert_equal("false", defined?(false))
+    assert_equal("expression", defined?(1))
   end
 
   def test_defined_impl_specific

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

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