From 257f78fb671151f1db06dcd8e35cf4cc736f735e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Barri=C3=A9?= Date: Mon, 14 Oct 2024 11:28:59 +0200 Subject: Show where mutated chilled strings were allocated [Feature #20205] The warning now suggests running with --debug-frozen-string-literal: ``` test.rb:3: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information) ``` When using --debug-frozen-string-literal, the location where the string was created is shown: ``` test.rb:3: warning: literal string will be frozen in the future test.rb:1: info: the string was created here ``` When resurrecting strings and debug mode is not enabled, the overhead is a simple FL_TEST_RAW. When mutating chilled strings and deprecation warnings are not enabled, the overhead is a simple warning category enabled check. Co-authored-by: Jean Boussier Co-authored-by: Nobuyoshi Nakada Co-authored-by: Jean Boussier --- test/ruby/test_rubyoptions.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'test/ruby') diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index f82861b8ce..f9a0d6055b 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -1262,9 +1262,8 @@ class TestRubyOptions < Test::Unit::TestCase code = <<~RUBY "foo" << "bar" RUBY - warning = ["-:1: warning: literal string will be frozen in the future"] - assert_in_out_err(["-W:deprecated"], code, [], warning) - assert_in_out_err(["-W:deprecated", "--debug-frozen-string-literal"], code, [], warning) + assert_in_out_err(["-W:deprecated"], code, [], ["-:1: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)"]) + assert_in_out_err(["-W:deprecated", "--debug-frozen-string-literal"], code, [], ["-:1: warning: literal string will be frozen in the future", "-:1: info: the string was created here"]) assert_in_out_err(["-W:deprecated", "--disable-frozen-string-literal", "--debug-frozen-string-literal"], code, [], []) assert_in_out_err(["-W:deprecated", "--enable-frozen-string-literal", "--debug-frozen-string-literal"], code, [], ["-:1:in '
': can't modify frozen String: \"foo\", created at -:1 (FrozenError)"]) end -- cgit v1.2.3