summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-10 00:12:05 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-10 00:12:05 +0000
commit70973af1d577756bd7b6dc236f3f2d53d9cfdd25 (patch)
tree3420ebd467e83c2b52db8e295e640634085f1e83 /parse.y
parent8f61bbf3140f234739a7f50a05c196ff7653c941 (diff)
parse.y: check for attr
* parse.y (rb_id_attrset): check if the argument is valid type as an attribute. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y22
1 files changed, 22 insertions, 0 deletions
diff --git a/parse.y b/parse.y
index f392be7bfa..8a31a74158 100644
--- a/parse.y
+++ b/parse.y
@@ -8766,9 +8766,31 @@ block_dup_check_gen(struct parser_params *parser, NODE *node1, NODE *node2)
}
}
+static const char id_type_names[][9] = {
+ "LOCAL",
+ "INSTANCE",
+ "", /* INSTANCE2 */
+ "GLOBAL",
+ "ATTRSET",
+ "CONST",
+ "CLASS",
+ "JUNK",
+};
+
ID
rb_id_attrset(ID id)
{
+ if (!is_notop_id(id)) {
+ rb_bug("rb_id_attrset: operator ID - %"PRIdVALUE, (VALUE)id);
+ }
+ else {
+ int scope = (int)(id & ID_SCOPE_MASK);
+ if (scope != ID_LOCAL && scope != ID_CONST) {
+ rb_bug("rb_id_attrset: %s ID - %"PRIdVALUE, id_type_names[scope],
+ (VALUE)id);
+
+ }
+ }
id &= ~ID_SCOPE_MASK;
id |= ID_ATTRSET;
return id;