mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-compiler: improve hash dump to display double-splat operator
Enhanced NODE_HASH dump to detect and display the double-splat operator (**) in a readable format. When a hash contains **other_hash syntax, the parser represents ** as MRB_OPSYM(pow). Instead of dumping this complex operator node, now displays a clean "**" for better readability. This makes hash dumps with splat operations much easier to understand and debug. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -8206,7 +8206,13 @@ dump_node(mrb_state *mrb, node *tree, int offset)
|
||||
while (pairs) {
|
||||
dump_prefix(offset+1, lineno);
|
||||
printf("key:\n");
|
||||
dump_node(mrb, pairs->car->car, offset+2);
|
||||
if (node_to_sym(pairs->car->car) == MRB_OPSYM(pow)) {
|
||||
dump_prefix(offset+2, lineno);
|
||||
printf("**\n");
|
||||
}
|
||||
else {
|
||||
dump_node(mrb, pairs->car->car, offset+2);
|
||||
}
|
||||
dump_prefix(offset+1, lineno);
|
||||
printf("value:\n");
|
||||
dump_node(mrb, pairs->car->cdr, offset+2);
|
||||
|
||||
@@ -15035,7 +15035,13 @@ dump_node(mrb_state *mrb, node *tree, int offset)
|
||||
while (pairs) {
|
||||
dump_prefix(offset+1, lineno);
|
||||
printf("key:\n");
|
||||
dump_node(mrb, pairs->car->car, offset+2);
|
||||
if (node_to_sym(pairs->car->car) == MRB_OPSYM(pow)) {
|
||||
dump_prefix(offset+2, lineno);
|
||||
printf("**:\n");
|
||||
}
|
||||
else {
|
||||
dump_node(mrb, pairs->car->car, offset+2);
|
||||
}
|
||||
dump_prefix(offset+1, lineno);
|
||||
printf("value:\n");
|
||||
dump_node(mrb, pairs->car->cdr, offset+2);
|
||||
|
||||
Reference in New Issue
Block a user