From: wanabe Date: 2008-05-11T15:06:11+09:00 Subject: [ruby-dev:34645] Re: defined? a &&= 0 ワナベと申します。 2008/05/04 17:05 Tanaka Akira : > 以下のように、defined? a &&= 0 が nil になりますが、これは意 > 図的でしょうか? 例外が起きない限り "expression" を返すようにするパッチを書きました。 catch テーブルの sp の計算上、無効な branchif をはさんであります。 正しくはどう書くのがよいのでしょうか。 ところで 1.8/1.9 共通の動作で、a が未定義のときに defined?(a||=0) とすると a == 0 になるのですが、これは正しい動作なのでしょうか。 Index: compile.c =================================================================== --- compile.c (revision 16303) +++ compile.c (working copy) @@ -2499,7 +2499,9 @@ if (!lfinish[1]) { lfinish[1] = NEW_LABEL(nd_line(node)); } - ADD_INSNL(ret, nd_line(node), branchunless, lfinish[1]); + ADD_INSN(ret, nd_line(node), pop); + ADD_INSN(ret, nd_line(node), putnil); + ADD_INSNL(ret, nd_line(node), branchif, lfinish[1]); if (needstr) { ADD_INSN1(ret, nd_line(node), putstring, rb_str_new2("expression")); } -- ワナベ