From 98ef38ada43338c073f50a0093196f0356284625 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Wed, 27 Nov 2019 11:40:18 +0000 Subject: Freeze Regexp literals [Feature #8948] [Feature #16377] Since Regexp literals always reference the same instance, allowing to mutate them can lead to state leak. --- spec/ruby/language/regexp_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'spec/ruby/language') diff --git a/spec/ruby/language/regexp_spec.rb b/spec/ruby/language/regexp_spec.rb index 67c7c034e9..5881afe6f1 100644 --- a/spec/ruby/language/regexp_spec.rb +++ b/spec/ruby/language/regexp_spec.rb @@ -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| -- cgit v1.2.3