aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--parse.y30
2 files changed, 31 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 7ebf45992a..69a691fd29 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
-Sat Jul 23 12:12:25 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Jul 23 12:19:04 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * parse.y (rb_check_id): take care of attrset ID created
+ implicitly by local ID. [Bug #5084]
* parse.y (rb_check_id): conversion condition was inverse.
[Bug #5084]
diff --git a/parse.y b/parse.y
index 9646350e2d..366090f903 100644
--- a/parse.y
+++ b/parse.y
@@ -10120,9 +10120,33 @@ rb_check_id(VALUE name)
}
name = tmp;
}
- if (!st_lookup(global_symbols.sym_id, (st_data_t)name, &id))
- return (ID)0;
- return (ID)id;
+
+ if (rb_enc_str_coderange(name) == ENC_CODERANGE_BROKEN) {
+ rb_raise(rb_eEncodingError, "invalid encoding symbol");
+ }
+
+ if (st_lookup(global_symbols.sym_id, (st_data_t)name, &id))
+ return (ID)id;
+
+ if (rb_is_attrset_name(name)) {
+ struct RString fake_str;
+ const VALUE localname = (VALUE)&fake_str;
+ /* make local name by chopping '=' */
+ fake_str.basic.flags = T_STRING|RSTRING_NOEMBED;
+ fake_str.basic.klass = rb_cString;
+ fake_str.as.heap.len = RSTRING_LEN(name) - 1;
+ fake_str.as.heap.ptr = RSTRING_PTR(name);
+ fake_str.as.heap.aux.capa = fake_str.as.heap.len;
+ rb_enc_copy(localname, name);
+ OBJ_FREEZE(localname);
+
+ if (st_lookup(global_symbols.sym_id, (st_data_t)localname, &id)) {
+ return rb_id_attrset((ID)id);
+ }
+ RB_GC_GUARD(name);
+ }
+
+ return (ID)0;
}
int