diff --git a/node.c b/node.c index 99558319f8..4c2810b0e2 100644 --- a/node.c +++ b/node.c @@ -1184,6 +1184,7 @@ void rb_ast_mark(rb_ast_t *ast) { if (ast->node_buffer) rb_gc_mark(ast->node_buffer->mark_ary); + if (ast->body.compile_option) rb_gc_mark(ast->body.compile_option); } void diff --git a/parse.y b/parse.y index 0edbc565a4..ade2e0a941 100644 --- a/parse.y +++ b/parse.y @@ -5807,9 +5807,8 @@ yycompile0(VALUE arg) if (!opt) opt = rb_obj_hide(rb_ident_hash_new()); rb_hash_aset(opt, rb_sym_intern_ascii_cstr("coverage_enabled"), cov); prelude = block_append(p, p->eval_tree_begin, body); - add_mark_object(p, opt); tree->nd_body = prelude; - p->ast->body.compile_option = opt; + RB_OBJ_WRITE(p->ast, &p->ast->body.compile_option, opt); } p->ast->body.root = tree; p->ast->body.line_count = p->line_count;