mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
freeze dynamic regexp literals
Regexp literals are frozen, and also dynamically comppiled Regexp literals (/#{expr}/) are frozen.
This commit is contained in:
parent
f8d264fdfd
commit
7ad56fd87b
Notes:
git
2020-10-27 01:46:23 +09:00
2 changed files with 4 additions and 1 deletions
4
re.c
4
re.c
|
@ -2944,7 +2944,9 @@ rb_reg_init_str_enc(VALUE re, VALUE s, rb_encoding *enc, int options)
|
|||
MJIT_FUNC_EXPORTED VALUE
|
||||
rb_reg_new_ary(VALUE ary, int opt)
|
||||
{
|
||||
return rb_reg_new_str(rb_reg_preprocess_dregexp(ary, opt), opt);
|
||||
VALUE re = rb_reg_new_str(rb_reg_preprocess_dregexp(ary, opt), opt);
|
||||
rb_obj_freeze(re);
|
||||
return re;
|
||||
}
|
||||
|
||||
VALUE
|
||||
|
|
|
@ -125,6 +125,7 @@ module Test
|
|||
filter = /\A(?=.*#{filter})(?!.*#{negative})/
|
||||
end
|
||||
if Regexp === filter
|
||||
filter = filter.dup
|
||||
# bypass conversion in minitest
|
||||
def filter.=~(other) # :nodoc:
|
||||
super unless Regexp === other
|
||||
|
|
Loading…
Add table
Reference in a new issue