1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* parse.y (dyna_push_gen, dyna_pop_gen): adjust local vtable level

for the case of syntax errors in method name or argument inside
  do block.   [ruby-core:26961]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-11-30 21:16:31 +00:00
parent be18999699
commit 9b02e165d3
4 changed files with 77 additions and 41 deletions

View file

@ -1,3 +1,9 @@
Tue Dec 1 06:16:29 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (dyna_push_gen, dyna_pop_gen): adjust local vtable level
for the case of syntax errors in method name or argument inside
do block. [ruby-core:26961]
Mon Nov 30 16:57:45 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/extmk.rb (command_output): $makeflags are already quoted.

View file

@ -836,3 +836,44 @@ assert_equal 'ok', %q{
assert_equal 'ok', %q{
"o" "#{}k"
}, '[ruby-dev:38980]'
bug2415 = '[ruby-core:26961]'
assert_normal_exit %q{
0.times do
0.times do
def x(a=1, b, *rest); nil end
end
end
}, bug2415
assert_normal_exit %q{
0.times do
0.times do
def x@; nil end
end
end
}, bug2415
assert_normal_exit %q{
0.times do
0.times do
def x(a = 0.times do
def y(a=1, b, *rest); nil; end
end)
nil
end
end
end
}, bug2415
assert_normal_exit %q{
0.times do
0.times do
def x(a = 0.times do
def x@; nil; end
end)
nil
end
end
end
}, bug2415

65
parse.y
View file

@ -453,10 +453,10 @@ static int local_id_gen(struct parser_params*, ID);
static ID internal_id_gen(struct parser_params*);
#define internal_id() internal_id_gen(parser)
static void dyna_push_gen(struct parser_params*);
#define dyna_push() dyna_push_gen(parser)
static void dyna_pop_gen(struct parser_params*);
#define dyna_pop() dyna_pop_gen(parser)
static NODE *dyna_push_gen(struct parser_params*, VALUE);
#define dyna_push(x) dyna_push_gen(parser, x)
static void dyna_pop_gen(struct parser_params*, NODE *);
#define dyna_pop(node) dyna_pop_gen(parser, node)
static int dyna_in_block_gen(struct parser_params*);
#define dyna_in_block() dyna_in_block_gen(parser)
#define dyna_var(id) local_var(id)
@ -1254,11 +1254,7 @@ block_command : block_call
cmd_brace_block : tLBRACE_ARG
{
dyna_push();
/*%%%*/
$<num>$ = ruby_sourceline;
/*%
%*/
$<node>$ = dyna_push(0);
}
opt_block_param
compstmt
@ -1266,11 +1262,11 @@ cmd_brace_block : tLBRACE_ARG
{
/*%%%*/
$$ = NEW_ITER($3,$4);
nd_set_line($$, $<num>2);
nd_set_line($$, nd_line($<node>2));
/*%
$$ = dispatch2(brace_block, escape_Qundef($3), $4);
%*/
dyna_pop();
dyna_pop($<node>2);
}
;
@ -3410,21 +3406,20 @@ bvar : tIDENTIFIER
;
lambda : {
dyna_push();
$<num>$ = lpar_beg;
$<node>$ = dyna_push((VALUE)lpar_beg);
lpar_beg = ++paren_nest;
}
f_larglist
lambda_body
{
lpar_beg = $<num>1;
lpar_beg = (int)$<node>1->u1.value;
/*%%%*/
$$ = $2;
$$->nd_body = NEW_SCOPE($2->nd_head, $3);
/*%
$$ = dispatch2(lambda, $2, $3);
%*/
dyna_pop();
dyna_pop($<node>1);
}
;
@ -3458,10 +3453,7 @@ lambda_body : tLAMBEG compstmt '}'
do_block : keyword_do_block
{
dyna_push();
/*%%%*/
$<num>$ = ruby_sourceline;
/*% %*/
$<node>$ = dyna_push(0);
}
opt_block_param
compstmt
@ -3469,11 +3461,11 @@ do_block : keyword_do_block
{
/*%%%*/
$$ = NEW_ITER($3,$4);
nd_set_line($$, $<num>2);
nd_set_line($$, nd_line($<node>2));
/*%
$$ = dispatch2(do_block, escape_Qundef($3), $4);
%*/
dyna_pop();
dyna_pop($<node>2);
}
;
@ -3604,41 +3596,33 @@ method_call : operation paren_args
brace_block : '{'
{
dyna_push();
/*%%%*/
$<num>$ = ruby_sourceline;
/*%
%*/
$<node>$ = dyna_push(0);
}
opt_block_param
compstmt '}'
{
/*%%%*/
$$ = NEW_ITER($3,$4);
nd_set_line($$, $<num>2);
nd_set_line($$, nd_line($<node>2));
/*%
$$ = dispatch2(brace_block, escape_Qundef($3), $4);
%*/
dyna_pop();
dyna_pop($<node>2);
}
| keyword_do
{
dyna_push();
/*%%%*/
$<num>$ = ruby_sourceline;
/*%
%*/
$<node>$ = dyna_push(0);
}
opt_block_param
compstmt keyword_end
{
/*%%%*/
$$ = NEW_ITER($3,$4);
nd_set_line($$, $<num>2);
nd_set_line($$, nd_line($<node>2));
/*%
$$ = dispatch2(do_block, escape_Qundef($3), $4);
%*/
dyna_pop();
dyna_pop($<node>2);
}
;
@ -8876,18 +8860,23 @@ local_id_gen(struct parser_params *parser, ID id)
}
}
static void
dyna_push_gen(struct parser_params *parser)
static NODE *
dyna_push_gen(struct parser_params *parser, VALUE x)
{
lvtbl->args = vtable_alloc(lvtbl->args);
lvtbl->vars = vtable_alloc(lvtbl->vars);
return node_newnode(parser, NODE_ZSUPER, (VALUE)lvtbl->args, (VALUE)lvtbl->vars, x);
}
static void
dyna_pop_gen(struct parser_params *parser)
dyna_pop_gen(struct parser_params *parser, NODE *dv)
{
struct vtable *tmp;
while (lvtbl->args != (struct vtable *)dv->u1.value) {
local_pop();
}
rb_gc_force_recycle((VALUE)dv);
tmp = lvtbl->args;
lvtbl->args = lvtbl->args->prev;
vtable_free(tmp);

View file

@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.2"
#define RUBY_RELEASE_DATE "2009-11-30"
#define RUBY_RELEASE_DATE "2009-12-01"
#define RUBY_PATCHLEVEL -1
#define RUBY_BRANCH_NAME "trunk"
@ -7,8 +7,8 @@
#define RUBY_VERSION_MINOR 9
#define RUBY_VERSION_TEENY 1
#define RUBY_RELEASE_YEAR 2009
#define RUBY_RELEASE_MONTH 11
#define RUBY_RELEASE_DAY 30
#define RUBY_RELEASE_MONTH 12
#define RUBY_RELEASE_DAY 1
#include "ruby/version.h"