1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Freeze Regexp literals

[Feature #8948] [Feature #16377]

Since Regexp literals always reference the same instance,
allowing to mutate them can lead to state leak.
This commit is contained in:
Jean Boussier 2019-11-27 11:40:18 +00:00 committed by Yusuke Endoh
parent 07aef4c99a
commit 98ef38ada4
Notes: git 2020-01-15 10:39:11 +09:00
8 changed files with 25 additions and 10 deletions

View file

@ -18,6 +18,12 @@ describe "Literal Regexps" do
/Hello/.should be_kind_of(Regexp)
end
ruby_version_is "2.7" do
it "is frozen" do
/Hello/.frozen?.should == true
end
end
it "caches the Regexp object" do
rs = []
2.times do |i|