diff options
| author | Yukihiro Matsumoto <[email protected]> | 2012-05-18 11:04:36 +0900 |
|---|---|---|
| committer | Yukihiro Matsumoto <[email protected]> | 2012-05-18 11:04:36 +0900 |
| commit | 61d8bb132e78d37670b0bc0055e5892eb5885e12 (patch) | |
| tree | 590d9ab9d349ed80b28943a7324b432fb46374fb /src | |
| parent | a18fb01b03a837a30d16e229d99d547b82505de2 (diff) | |
| download | mruby-61d8bb132e78d37670b0bc0055e5892eb5885e12.tar.gz mruby-61d8bb132e78d37670b0bc0055e5892eb5885e12.zip | |
keep toplevel local variables; close #133
Diffstat (limited to 'src')
| -rw-r--r-- | src/parse.y | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/parse.y b/src/parse.y index ec04ae8a6..35eff1b33 100644 --- a/src/parse.y +++ b/src/parse.y @@ -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; |
