mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-compiler: fix NODE_HEREDOC parser dump crash
Replace dump_recur() with dump_str() in NODE_HEREDOC case to properly handle cons-lists of string representations instead of AST nodes. This fixes segmentation faults when dumping heredoc AST nodes. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -8343,8 +8343,24 @@ dump_node(mrb_state *mrb, node *tree, int offset)
|
||||
break;
|
||||
|
||||
case NODE_HEREDOC:
|
||||
printf("NODE_HEREDOC (<<%s):\n", ((parser_heredoc_info*)tree)->term);
|
||||
dump_recur(mrb, ((parser_heredoc_info*)tree)->doc, offset+1);
|
||||
printf("NODE_HEREDOC:\n");
|
||||
if (heredoc_node(tree)->info.term) {
|
||||
dump_prefix(offset+1, lineno);
|
||||
printf("terminator: \"%s\"\n", heredoc_node(tree)->info.term);
|
||||
}
|
||||
if (heredoc_node(tree)->info.doc) {
|
||||
dump_prefix(offset+1, lineno);
|
||||
printf("body:\n");
|
||||
dump_str(mrb, heredoc_node(tree)->info.doc, offset+2, lineno);
|
||||
}
|
||||
if (heredoc_node(tree)->info.allow_indent) {
|
||||
dump_prefix(offset+1, lineno);
|
||||
printf("allow_indent: true\n");
|
||||
}
|
||||
if (heredoc_node(tree)->info.remove_indent) {
|
||||
dump_prefix(offset+1, lineno);
|
||||
printf("remove_indent: true\n");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -15172,8 +15172,24 @@ dump_node(mrb_state *mrb, node *tree, int offset)
|
||||
break;
|
||||
|
||||
case NODE_HEREDOC:
|
||||
printf("NODE_HEREDOC (<<%s):\n", ((parser_heredoc_info*)tree)->term);
|
||||
dump_recur(mrb, ((parser_heredoc_info*)tree)->doc, offset+1);
|
||||
printf("NODE_HEREDOC:\n");
|
||||
if (heredoc_node(tree)->info.term) {
|
||||
dump_prefix(offset+1, lineno);
|
||||
printf("terminator: \"%s\"\n", heredoc_node(tree)->info.term);
|
||||
}
|
||||
if (heredoc_node(tree)->info.doc) {
|
||||
dump_prefix(offset+1, lineno);
|
||||
printf("body:\n");
|
||||
dump_str(mrb, heredoc_node(tree)->info.doc, offset+2, lineno);
|
||||
}
|
||||
if (heredoc_node(tree)->info.allow_indent) {
|
||||
dump_prefix(offset+1, lineno);
|
||||
printf("allow_indent: true\n");
|
||||
}
|
||||
if (heredoc_node(tree)->info.remove_indent) {
|
||||
dump_prefix(offset+1, lineno);
|
||||
printf("remove_indent: true\n");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user