diff options
author | Aaron Patterson <tenderlove@ruby-lang.org> | 2019-09-10 11:27:40 -0700 |
---|---|---|
committer | Aaron Patterson <tenderlove@ruby-lang.org> | 2019-09-10 12:42:35 -0700 |
commit | 139510238bcbb8d7fd8022c23a603c51d2acbe2e (patch) | |
tree | c7329e0a00ac14301b2c978864aa871a07c8b38d | |
parent | 721cab470606294e5b49ef75793a62becdf5cfb7 (diff) | |
download | ruby-139510238bcbb8d7fd8022c23a603c51d2acbe2e.tar.gz |
WB needs to be executed after object is reachable
-rw-r--r-- | node.h | 7 | ||||
-rw-r--r-- | parse.y | 8 |
2 files changed, 10 insertions, 5 deletions
@@ -284,7 +284,12 @@ typedef struct RNode { #define NEW_DEFN(i,a,d,loc) NEW_NODE(NODE_DEFN,0,i,NEW_SCOPE(a,d,loc),loc) #define NEW_DEFS(r,i,a,d,loc) NEW_NODE(NODE_DEFS,r,i,NEW_SCOPE(a,d,loc),loc) -#define NEW_SCOPE(a,b,loc) NEW_NODE(NODE_SCOPE,local_tbl(p),b,a,loc) +#define NEW_SCOPE(a,b,loc) ({ \ + VALUE tbl = 0; \ + NODE * _n = NEW_NODE(NODE_SCOPE,local_tbl(p, &tbl),b,a,loc); \ + tbl && RB_OBJ_WRITTEN(p->ast, Qnil, tbl); \ + _n; \ +}) #define NEW_BLOCK(a,loc) NEW_NODE(NODE_BLOCK,a,0,0,loc) #define NEW_IF(c,t,e,loc) NEW_NODE(NODE_IF,c,t,e,loc) #define NEW_UNLESS(c,t,e,loc) NEW_NODE(NODE_UNLESS,c,t,e,loc) @@ -465,7 +465,7 @@ static NODE *symbol_append(struct parser_params *p, NODE *symbols, NODE *symbol) static NODE *match_op(struct parser_params*,NODE*,NODE*,const YYLTYPE*,const YYLTYPE*); -static ID *local_tbl(struct parser_params*); +static ID *local_tbl(struct parser_params*, VALUE *tmp); static VALUE reg_compile(struct parser_params*, VALUE, int); static void reg_fragment_setenc(struct parser_params*, VALUE, int); @@ -11144,8 +11144,8 @@ new_args_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, ID block, args = ZALLOC(struct rb_args_info); VALUE tmpbuf = rb_imemo_tmpbuf_auto_free_pointer(args); args->imemo = tmpbuf; - RB_OBJ_WRITTEN(p->ast, Qnil, tmpbuf); node = NEW_NODE(NODE_ARGS, 0, 0, args, &NULL_LOC); + RB_OBJ_WRITTEN(p->ast, Qnil, tmpbuf); if (p->error_p) return node; args->block_arg = block; @@ -11633,7 +11633,7 @@ local_pop(struct parser_params *p) #ifndef RIPPER static ID* -local_tbl(struct parser_params *p) +local_tbl(struct parser_params *p, VALUE *tmp) { int cnt_args = vtable_size(p->lvtbl->args); int cnt_vars = vtable_size(p->lvtbl->vars); @@ -11655,8 +11655,8 @@ local_tbl(struct parser_params *p) buf[0] = cnt; VALUE tmpbuf = rb_imemo_tmpbuf_auto_free_pointer(buf); + *tmp = tmpbuf; buf[cnt + 1] = (ID)tmpbuf; - RB_OBJ_WRITTEN(p->ast, Qnil, tmpbuf); return buf; } |