summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-12-06 10:53:51 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-12-06 10:53:51 +0000
commita472da8900a5e763da11a2c010be74756112d69d (patch)
tree81d114776781ca5cecf9da1cfa20da0d1fde93ab
parent2aee0d514432f05cf7baa9581d71c4366f188bce (diff)
downloadruby-a472da8900a5e763da11a2c010be74756112d69d.tar.gz
backport from ruby_1_8
* 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_5@11356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--parse.y24
-rw-r--r--version.h2
3 files changed, 28 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index db566b17f4..b552e39ba9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Dec 4 10:43:46 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (dyna_init_gen): dvar initialization only if dvar is
+ assigned inner block. [ruby-talk:227402]
+
Mon Dec 4 10:22:26 2006 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
* stable version 1.8.5-p2 relased.
diff --git a/parse.y b/parse.y
index 7b05c18f46..14561ca185 100644
--- a/parse.y
+++ b/parse.y
@@ -4866,6 +4866,8 @@ gettable(id)
return 0;
}
+static VALUE dyna_var_lookup _((ID id));
+
static NODE*
assignable(id, val)
ID id;
@@ -4894,7 +4896,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()) {
@@ -5736,6 +5738,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()
{
@@ -5770,7 +5788,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);
}
diff --git a/version.h b/version.h
index e792de4380..06e0b32960 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2006-12-06"
#define RUBY_VERSION_CODE 185
#define RUBY_RELEASE_CODE 20061206
-#define RUBY_PATCHLEVEL 6
+#define RUBY_PATCHLEVEL 7
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8