diff options
author | Étienne Barrié <[email protected]> | 2024-10-14 11:28:59 +0200 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2024-10-21 12:33:02 +0200 |
commit | 257f78fb671151f1db06dcd8e35cf4cc736f735e (patch) | |
tree | cf67eb44cc8134d82eac7d688b23fe33a9ba7910 /test/ruby | |
parent | 75ef89ca16d2c94e845b80e8b97bfc811370a890 (diff) |
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 <[email protected]>
Co-authored-by: Nobuyoshi Nakada <[email protected]>
Co-authored-by: Jean Boussier <[email protected]>
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/11893
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_rubyoptions.rb | 5 |
1 files changed, 2 insertions, 3 deletions
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 '<main>': can't modify frozen String: \"foo\", created at -:1 (FrozenError)"]) end |