From 4cb9e9f553101420ced194bacbaaba718cba9ee9 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 30 Sep 2025 13:55:04 +0900 Subject: [PATCH] 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 --- mrbgems/mruby-compiler/core/parse.y | 8 +++++++- mrbgems/mruby-compiler/core/y.tab.c | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y index bb253a78c..890f9e905 100644 --- a/mrbgems/mruby-compiler/core/parse.y +++ b/mrbgems/mruby-compiler/core/parse.y @@ -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); diff --git a/mrbgems/mruby-compiler/core/y.tab.c b/mrbgems/mruby-compiler/core/y.tab.c index 7941cde0b..4c3c86a11 100644 --- a/mrbgems/mruby-compiler/core/y.tab.c +++ b/mrbgems/mruby-compiler/core/y.tab.c @@ -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);