keep toplevel local variables; close #133

This commit is contained in:
Yukihiro Matsumoto
2012-05-18 11:04:36 +09:00
parent a18fb01b03
commit 61d8bb132e
2 changed files with 11 additions and 4 deletions
+4 -2
View File
@@ -967,12 +967,11 @@ var_reference(parser_state *p, node *lhs)
%%
program : {
p->lstate = EXPR_BEG;
local_nest(p);
if (!p->locals) p->locals = cons(0,0);
}
top_compstmt
{
p->tree = new_scope(p, $2);
local_unnest(p);
}
;
@@ -4631,6 +4630,9 @@ mrb_parser_parse(parser_state *p)
}
yyparse(p);
tree = p->tree;
if ((int)tree->car == NODE_SCOPE) {
p->locals = cons(tree->cdr->car, 0);
}
if (!tree) {
if (p->begin_tree) {
tree = p->begin_tree;