@@ -3289,15 +3289,19 @@ basic_expr:
3289
3289
$$ = AstNode::mkconst_str(@1, *$1);
3290
3290
SET_AST_NODE_LOC($$.get(), @1, @1);
3291
3291
} |
3292
- hierarchical_id attr {
3293
- // super sketchy! Orphaned pointer in non-owning extra->ast_stack
3294
- AstNode *node = new AstNode(@1, AST_FCALL);
3295
- node->str = *$1;
3296
- extra->ast_stack.push_back(node);
3297
- SET_AST_NODE_LOC(node, @1, @1);
3298
- append_attr(node, std::move($2));
3292
+ hierarchical_id attr <ast_t>{
3293
+ // Here we use "Typed Midrule Actions".
3294
+ // https://www.gnu.org/software/bison/manual/html_node/Typed-Midrule-Actions.html
3295
+ auto fcall = std::make_unique<AstNode>(@1, AST_FCALL);
3296
+ AstNode *fcall_node = fcall.get();
3297
+ fcall_node->str = *$1;
3298
+ extra->ast_stack.push_back(fcall_node);
3299
+ SET_AST_NODE_LOC(fcall_node, @1, @1);
3300
+ append_attr(fcall_node, std::move($2));
3301
+ $$ = std::move(fcall);
3299
3302
} TOK_LPAREN arg_list optional_comma TOK_RPAREN {
3300
- $$.reset(extra->ast_stack.back());
3303
+ log_assert($3 != nullptr);
3304
+ $$ = std::move($3);
3301
3305
extra->ast_stack.pop_back();
3302
3306
} |
3303
3307
TOK_TO_SIGNED attr TOK_LPAREN expr TOK_RPAREN {
0 commit comments