From: "mdalessio (Mike Dalessio) via ruby-core" <ruby-core@ml.ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Cc: "mdalessio (Mike Dalessio)" <noreply@ruby-lang.org>
Subject: [ruby-core:117303] [Ruby master Bug#20389] Issue with chilled strings and mutability after 12be40ae
Date: Sun, 24 Mar 2024 13:35:31 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-107444.20240324133531.443@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-20389.20240324133343.443@ruby-lang.org
Issue #20389 has been updated by mdalessio (Mike Dalessio).
Description updated
tagging @byroot @etienne
----------------------------------------
Bug #20389: Issue with chilled strings and mutability after 12be40ae
https://bugs.ruby-lang.org/issues/20389#change-107444
* Author: mdalessio (Mike Dalessio)
* Status: Open
* ruby -v: ruby 3.4.0dev (2024-03-23T16:40:17Z master 8265a7531f) [x86_64-linux]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
Commit 12be40ae introduced the concept of "chilled" strings when code is compiled with frozen-string-literals not explicitly enabled or disabled. I believe I've found a related bug, which I've bisected to this commit.
This reproduction has been simplified from a failing test case in the `http-cookie` gem:
``` ruby
puts RUBY_DESCRIPTION
re = %r{.(?<thing>.*)}
input = "x/dir[]/file.html"
match = re.match(input) # => "#<MatchData \"x/dir[]/file.html\" thing:\"/dir[]/file.html\">"
thing = match[:thing]
puts "before: #{thing.inspect}"
input[match.begin(:thing)...match.end(:thing)] = "/dir%5B%5D/file.html"
puts "after : #{thing.inspect}"
exit 1 unless thing == "/dir[]/file.html"
```
Ruby 3.3.0 and earlier is fine:
```
$ ruby ./issue-chilled-strings.rb
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-linux]
before: "/dir[]/file.html"
after : "/dir[]/file.html"
```
Master with frozen string explicitly disabled passes:
```
$ ruby --disable-frozen-string-literal ./issue-chilled-strings.rb
ruby 3.4.0dev (2024-03-23T16:40:17Z master 8265a7531f) [x86_64-linux]
before: "/dir[]/file.html"
after : "/dir[]/file.html"
```
Master with frozen strings explicitly enabled fails as expected:
```
$ ruby --enable-frozen-string-literal ./issue-chilled-strings.rb
ruby 3.4.0dev (2024-03-23T16:40:17Z master 8265a7531f) [x86_64-linux]
before: "/dir[]/file.html"
./issue-chilled-strings.rb:12:in 'String#[]=': can't modify frozen String: "x/dir[]/file.html" (FrozenError)
from ./issue-chilled-strings.rb:12:in '<main>'
```
But master with no frozen string setting ("chilled") fails, and modifies what should be a frozen string:
```
$ ruby ./issue-chilled-strings.rb
ruby 3.4.0dev (2024-03-23T16:40:17Z master 8265a7531f) [x86_64-linux]
before: "/dir[]/file.html"
after : "/dir%5B%5D/file."
```
I believe in this case, the chilled warning should be emitted, but then the frozen string should not be modified.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
next prev parent reply other threads:[~2024-03-24 13:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-24 13:33 [ruby-core:117302] [Ruby master Bug#20389] Issue with chilled strings and mutability after 12be40ae mdalessio (Mike Dalessio) via ruby-core
2024-03-24 13:35 ` mdalessio (Mike Dalessio) via ruby-core [this message]
2024-03-24 15:09 ` [ruby-core:117304] " byroot (Jean Boussier) via ruby-core
2024-03-25 9:02 ` [ruby-core:117311] " byroot (Jean Boussier) via ruby-core
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-107444.20240324133531.443@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
--cc=noreply@ruby-lang.org \
--cc=ruby-core@ml.ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).