summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-10-29 09:42:18 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-10-29 09:42:18 +0000
commitf3cbb20b2272ea5b1c9cafb16e22221aa527f952 (patch)
tree9deebe3ddac9283f93dc90e9855de48270637a18 /parse.y
parent2ae60f16349a0fdbe1094ad2eb5283fb4e71970d (diff)
* parse.y (bvar): block-local variable can shadow outer variable.
[ruby-core:13036] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y13
1 files changed, 10 insertions, 3 deletions
diff --git a/parse.y b/parse.y
index 355c9afa71..f7c2bb46a2 100644
--- a/parse.y
+++ b/parse.y
@@ -669,7 +669,7 @@ static void ripper_compile_error(struct parser_params*, const char *fmt, ...);
%type <node> brace_block cmd_brace_block do_block lhs none fitem
%type <node> mlhs mlhs_head mlhs_basic mlhs_item mlhs_node mlhs_post mlhs_inner
%type <id> fsym variable sym symbol operation operation2 operation3
-%type <id> cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg
+%type <id> cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg f_bad_arg
/*%%%*/
/*%
%type <val> program reswords then do dot_or_colon
@@ -3250,7 +3250,7 @@ bv_decls : bvar
%*/
;
-bvar : f_norm_arg
+bvar : tIDENTIFIER
{
/*%%%*/
new_bv($1);
@@ -3258,6 +3258,10 @@ bvar : f_norm_arg
$$ = $1;
%*/
}
+ | f_bad_arg
+ {
+ $$ = 0;
+ }
;
lambda : {
@@ -4135,7 +4139,7 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg
}
;
-f_norm_arg : tCONSTANT
+f_bad_arg : tCONSTANT
{
/*%%%*/
yyerror("formal argument cannot be a constant");
@@ -4171,6 +4175,9 @@ f_norm_arg : tCONSTANT
$$ = dispatch1(param_error, $1);
%*/
}
+ ;
+
+f_norm_arg : f_bad_arg
| tIDENTIFIER
{
/*%%%*/