summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bootstraptest/test_insns.rb1
-rw-r--r--compile.c3
2 files changed, 3 insertions, 1 deletions
diff --git a/bootstraptest/test_insns.rb b/bootstraptest/test_insns.rb
index 2001e2c0ef..3a6e677885 100644
--- a/bootstraptest/test_insns.rb
+++ b/bootstraptest/test_insns.rb
@@ -178,6 +178,7 @@ tests = [
},
[ 'opt_str_freeze', %q{ 'true'.freeze }, ],
+ [ 'opt_str_freeze', %q{ -'true' }, ],
[ 'opt_str_freeze', <<~'},', ], # {
class String
def freeze
diff --git a/compile.c b/compile.c
index f1ba0946b3..be38c63dea 100644
--- a/compile.c
+++ b/compile.c
@@ -5188,7 +5188,8 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int poppe
* "literal".freeze -> opt_str_freeze("literal")
*/
if (node->nd_recv && nd_type(node->nd_recv) == NODE_STR &&
- node->nd_mid == idFreeze && node->nd_args == NULL &&
+ (node->nd_mid == idFreeze || node->nd_mid == idUMinus) &&
+ node->nd_args == NULL &&
ISEQ_COMPILE_DATA(iseq)->current_block == NULL &&
ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction) {
VALUE str = rb_fstring(node->nd_recv->nd_lit);