Skip to content

Commit a60dfb3

Browse files
committedMay 24, 2015
Reintroduce TypeError raising for Regexp.new
Regexp.new should raise a TypeError if the given Pattern is an Fixnum or Float object
1 parent cbae591 commit a60dfb3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed
 

Diff for: ‎kernel/common/regexp.rb

+2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ def initialize(pattern, opts=nil, lang=nil)
128128
if pattern.kind_of?(Regexp)
129129
opts = pattern.options
130130
pattern = pattern.source
131+
elsif pattern.kind_of?(Fixnum) or pattern.kind_of?(Float)
132+
raise TypeError, "can't convert Fixnum into String"
131133
elsif opts.kind_of?(Fixnum)
132134
opts = opts & (OPTION_MASK | KCODE_MASK) if opts > 0
133135
elsif opts

0 commit comments

Comments
 (0)