diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-29 13:56:33 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-29 13:56:33 +0000 |
commit | 771c8ed338ac77d3f75acf44cd711f80c80cbe71 (patch) | |
tree | 3849c4cb7589d00a49ccbe4e6d36e77e3390ed26 /parse.y | |
parent | 3dab183c8276c6d53c9ac4404967b18f4c10d166 (diff) | |
download | ruby-771c8ed338ac77d3f75acf44cd711f80c80cbe71.tar.gz |
parse.y: fix inconsistency with literals
* parse.y (rb_id_attrset): fix inconsistency with literals, allow
ID_ATTRSET and return it itself, but ID_JUNK cannot make ID_ATTRSET.
and raise a NameError instead of rb_bug() for invalid argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -8885,17 +8885,23 @@ ID rb_id_attrset(ID id) { if (!is_notop_id(id)) { - rb_bug("rb_id_attrset: operator ID - %"PRIdVALUE, (VALUE)id); + switch (id) { + case tAREF: case tASET: + return tASET; /* only exception */ + } + rb_name_error(id, "cannot make operator ID :%s attrset", rb_id2name(id)); } else { int scope = (int)(id & ID_SCOPE_MASK); switch (scope) { case ID_LOCAL: case ID_INSTANCE: case ID_GLOBAL: - case ID_CONST: case ID_CLASS: case ID_JUNK: + case ID_CONST: case ID_CLASS: break; + case ID_ATTRSET: + return id; default: - rb_bug("rb_id_attrset: %s ID - %"PRIdVALUE, id_type_names[scope], - (VALUE)id); + rb_name_error(id, "cannot make %s ID %+"PRIsVALUE" attrset", + id_type_names[scope], ID2SYM(id)); } } |