From 4c13188ea6cb0a74f43542c1b485a4aaf1d1a5be Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 8 Feb 2022 12:44:50 +0900 Subject: [PATCH] codegen.c: generate `OP_HASH` in `gen_hash()` if `limit` exceeds. That means when `limit` is `0` it should always generate a hash. --- mrbgems/mruby-compiler/core/codegen.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index 70b7d3703..4a9fb9aeb 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -1643,6 +1643,12 @@ gen_hash(codegen_scope *s, node *tree, int val, int limit) len = 0; } } + if (val && len > limit) { + pop_n(len*2); + genop_2(s, OP_HASH, cursp(), len); + push(); + return -1; + } if (update) { if (val && len > 0) { pop_n(len*2+1);