Created
August 7, 2012 13:44
-
-
Save wanabe/3285445 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/compile.c b/compile.c | |
| index 5d028c9..25e96e7 100644 | |
| --- a/compile.c | |
| +++ b/compile.c | |
| @@ -3859,7 +3859,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) | |
| ADD_INSN(ret, nd_line(node), dup); | |
| } | |
| - if (node->nd_vid) { | |
| + if (!node->nd_else) { | |
| ADD_INSN1(ret, nd_line(node), putspecialobject, | |
| INT2FIX(VM_SPECIAL_OBJECT_CONST_BASE)); | |
| ADD_INSN1(ret, nd_line(node), setconstant, ID2SYM(node->nd_vid)); | |
| diff --git a/parse.y b/parse.y | |
| index cc0bae5..0332412 100644 | |
| --- a/parse.y | |
| +++ b/parse.y | |
| @@ -1218,17 +1218,6 @@ stmt : keyword_alias fitem {lex_state = EXPR_FNAME;} fitem | |
| $$ = dispatch3(opassign, $$, $4, $5); | |
| %*/ | |
| } | |
| - | primary_value tCOLON2 tCONSTANT tOP_ASGN command_call | |
| - { | |
| - /*%%%*/ | |
| - yyerror("constant re-assignment"); | |
| - $$ = 0; | |
| - /*% | |
| - $$ = dispatch2(const_path_field, $1, $3); | |
| - $$ = dispatch3(opassign, $$, $4, $5); | |
| - $$ = dispatch1(assign_error, $$); | |
| - %*/ | |
| - } | |
| | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call | |
| { | |
| /*%%%*/ | |
| @@ -2107,28 +2096,6 @@ arg : lhs '=' arg | |
| $$ = dispatch3(opassign, $1, $4, $5); | |
| %*/ | |
| } | |
| - | primary_value tCOLON2 tCONSTANT tOP_ASGN arg | |
| - { | |
| - /*%%%*/ | |
| - yyerror("constant re-assignment"); | |
| - $$ = NEW_BEGIN(0); | |
| - /*% | |
| - $$ = dispatch2(const_path_field, $1, $3); | |
| - $$ = dispatch3(opassign, $$, $4, $5); | |
| - $$ = dispatch1(assign_error, $$); | |
| - %*/ | |
| - } | |
| - | tCOLON3 tCONSTANT tOP_ASGN arg | |
| - { | |
| - /*%%%*/ | |
| - yyerror("constant re-assignment"); | |
| - $$ = NEW_BEGIN(0); | |
| - /*% | |
| - $$ = dispatch1(top_const_field, $2); | |
| - $$ = dispatch3(opassign, $$, $3, $4); | |
| - $$ = dispatch1(assign_error, $$); | |
| - %*/ | |
| - } | |
| | backref tOP_ASGN arg | |
| { | |
| /*%%%*/ | |
| @@ -4494,6 +4461,31 @@ var_lhs : user_variable | |
| $$ = dispatch1(var_field, $$); | |
| %*/ | |
| } | |
| + | tCOLON3 tCONSTANT | |
| + { | |
| + /*%%%*/ | |
| + if (in_def || in_single) | |
| + yyerror("dynamic constant assignment"); | |
| + $$ = NEW_CDECL($2, 0, NEW_COLON3($2)); | |
| + /*% | |
| + $$ = dispatch1(top_const_field, $2); | |
| + if (in_def || in_single) { | |
| + $$ = dispatch1(assign_error, $$); | |
| + } | |
| + %*/ | |
| + } | |
| + | primary_value tCOLON2 tCONSTANT | |
| + { | |
| + /*%%%*/ | |
| + if (in_def || in_single) | |
| + yyerror("dynamic constant assignment"); | |
| + $$ = NEW_CDECL($3, 0, NEW_COLON2($1, $3)); | |
| + /*% | |
| + if (in_def || in_single) | |
| + yyerror("dynamic constant assignment"); | |
| + $$ = dispatch2(const_path_field, $1, $3); | |
| + %*/ | |
| + } | |
| ; | |
| backref : tNTH_REF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment