diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-12-04 08:03:54 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-12-04 08:03:54 +0000 |
commit | b52503466de55a90ce9062eb1e1f7a624a2b112d (patch) | |
tree | 1cd57b8b3465dade8adda283f77a1f7249285798 /parse.y | |
parent | f5d69fc57c1d7edd9e94f5a2d2fdc8e2c43b9d1b (diff) |
* parse.y (dyna_init_gen): dvar initialization only if dvar is
assigned inner block. [ruby-talk:227402]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 24 |
1 files changed, 22 insertions, 2 deletions
@@ -4861,6 +4861,8 @@ gettable(id) return 0; } +static VALUE dyna_var_lookup _((ID id)); + static NODE* assignable(id, val) ID id; @@ -4889,7 +4891,7 @@ assignable(id, val) if (rb_dvar_curr(id)) { return NEW_DASGN_CURR(id, val); } - else if (rb_dvar_defined(id)) { + else if (dyna_var_lookup(id)) { return NEW_DASGN(id, val); } else if (local_id(id) || !dyna_in_block()) { @@ -5731,6 +5733,22 @@ top_local_setup() local_pop(); } +static VALUE +dyna_var_lookup(id) + ID id; +{ + struct RVarmap *vars = ruby_dyna_vars; + + while (vars) { + if (vars->id == id) { + vars->val = Qtrue; + return Qtrue; + } + vars = vars->next; + } + return Qfalse; +} + static struct RVarmap* dyna_push() { @@ -5765,7 +5783,9 @@ dyna_init(node, pre) if (!node || !post || pre == post) return node; for (var = 0; post != pre && post->id; post = post->next) { - var = NEW_DASGN_CURR(post->id, var); + if (RTEST(post->val)) { + var = NEW_DASGN_CURR(post->id, var); + } } return block_append(var, node); } |