p->tree may be NULL; close #161

This commit is contained in:
Yukihiro Matsumoto
2012-05-19 15:37:41 +09:00
parent 6421887917
commit cb8b4691f0
+8 -6
View File
@@ -4630,9 +4630,6 @@ mrb_parser_parse(parser_state *p)
} }
yyparse(p); yyparse(p);
tree = p->tree; tree = p->tree;
if ((int)tree->car == NODE_SCOPE) {
p->locals = cons(tree->cdr->car, 0);
}
if (!tree) { if (!tree) {
if (p->begin_tree) { if (p->begin_tree) {
tree = p->begin_tree; tree = p->begin_tree;
@@ -4641,9 +4638,14 @@ mrb_parser_parse(parser_state *p)
tree = new_nil(p); tree = new_nil(p);
} }
} }
else if (p->begin_tree) { else {
tree = new_begin(p, p->begin_tree); if ((int)tree->car == NODE_SCOPE) {
append(tree, p->tree); p->locals = cons(tree->cdr->car, 0);
}
if (p->begin_tree) {
tree = new_begin(p, p->begin_tree);
append(tree, p->tree);
}
} }
} }