From 050a10c607e471bb2f387eb9644db5ee9e43c46b Mon Sep 17 00:00:00 2001 From: matz Date: Fri, 23 Nov 2007 01:46:44 +0000 Subject: [PATCH] * compile.c (defined_expr): defined(method(x)) dumped core. a patch from Yusuke ENDOH . [ruby-dev:32335] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ compile.c | 7 ++----- test/ruby/test_defined.rb | 13 +++++++++++-- version.h | 6 +++--- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index e4031f1dfb..0b2e841352 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Nov 23 10:44:24 2007 Yukihiro Matsumoto + + * compile.c (defined_expr): defined(method(x)) dumped core. a + patch from Yusuke ENDOH . [ruby-dev:32335] + Wed Nov 21 18:03:49 2007 Koichi Sasada * vm.c: fix to recycle thread data (VM stack). diff --git a/compile.c b/compile.c index 91c94276c7..ce462fef0d 100644 --- a/compile.c +++ b/compile.c @@ -2295,13 +2295,11 @@ defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *ret, if (node->nd_args) { lfalse = NEW_LABEL(nd_line(node)); defined_expr(iseq, ret, node->nd_args, lfinish, Qfalse); + ADD_INSNL(ret, nd_line(node), branchunless, lfalse); } if (!self) { LABEL *lcont = NEW_LABEL(nd_line(node)); - if (lfalse) { - ADD_INSNL(ret, nd_line(node), branchunless, lfalse); - } defined_expr(iseq, ret, node->nd_recv, lfinish, Qfalse); ADD_INSNL(ret, nd_line(node), branchif, lcont); if (lfalse) { @@ -2319,9 +2317,8 @@ defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *ret, ADD_INSN(ret, nd_line(node), putself); ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_FUNC), ID2SYM(node->nd_mid), needstr); + ADD_INSNL(ret, nd_line(node), jump, lfinish); if (lfalse) { - ADD_INSNL(ret, nd_line(node), branchif, lfinish); - ADD_LABEL(ret, lfalse); ADD_INSN(ret, nd_line(node), putnil); ADD_INSNL(ret, nd_line(node), jump, lfinish); diff --git a/test/ruby/test_defined.rb b/test/ruby/test_defined.rb index 8a7fcf45a9..84b9bf7b9e 100644 --- a/test/ruby/test_defined.rb +++ b/test/ruby/test_defined.rb @@ -10,6 +10,8 @@ class TestDefined < Test::Unit::TestCase yield(defined?(self.foo)) yield(defined?(f.foo)) end + def baz(f) + end end def defined_test @@ -34,10 +36,17 @@ class TestDefined < Test::Unit::TestCase assert(defined?(1 == 2)) # operator expression f = Foo.new - assert_nil(defined?(f.foo)) + assert_nil(defined?(f.foo)) # protected method f.bar(f) { |v| assert(v) } + assert_nil(defined?(f.quux)) # undefined method + assert_nil(defined?(f.baz(x))) # undefined argument + x = 0 + assert(defined?(f.baz(x))) + assert_nil(defined?(f.quux(x))) + assert(defined?(print(x))) + assert_nil(defined?(quux(x))) assert(defined_test) # not iterator - assert(!defined_test{}) # called as iterator + assert(!defined_test{}) # called as iterator end end diff --git a/version.h b/version.h index efa62db775..be679a4476 100644 --- a/version.h +++ b/version.h @@ -1,7 +1,7 @@ #define RUBY_VERSION "1.9.0" -#define RUBY_RELEASE_DATE "2007-11-22" +#define RUBY_RELEASE_DATE "2007-11-23" #define RUBY_VERSION_CODE 190 -#define RUBY_RELEASE_CODE 20071122 +#define RUBY_RELEASE_CODE 20071123 #define RUBY_PATCHLEVEL 0 #define RUBY_VERSION_MAJOR 1 @@ -9,7 +9,7 @@ #define RUBY_VERSION_TEENY 0 #define RUBY_RELEASE_YEAR 2007 #define RUBY_RELEASE_MONTH 11 -#define RUBY_RELEASE_DAY 22 +#define RUBY_RELEASE_DAY 23 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[];