Skip to content

Commit

Permalink
Reintroduce TypeError raising for Regexp.new
Browse files Browse the repository at this point in the history
Regexp.new should raise a TypeError if the given Pattern is an
Fixnum or Float object
  • Loading branch information
tak1n committed May 24, 2015
1 parent cbae591 commit a60dfb3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions kernel/common/regexp.rb
Expand Up @@ -128,6 +128,8 @@ def initialize(pattern, opts=nil, lang=nil)
if pattern.kind_of?(Regexp)
opts = pattern.options
pattern = pattern.source
elsif pattern.kind_of?(Fixnum) or pattern.kind_of?(Float)
raise TypeError, "can't convert Fixnum into String"
elsif opts.kind_of?(Fixnum)
opts = opts & (OPTION_MASK | KCODE_MASK) if opts > 0
elsif opts
Expand Down

0 comments on commit a60dfb3

Please sign in to comment.