[ruby-core:96081] [Ruby master Feature#13083] Regexp#{match, match?} with a nil argument are deprecated and will raise a TypeError in Ruby 3.0

[email protected]
Newsgroups gmane.comp.lang.ruby.core
Message-ID <redmine.journal-82930.20191203133439.5fb09dd3f9833b74@ruby-lang.org>
Issue #13083 has been updated by matz (Yukihiro Matsumoto).


It's not my intention to suffer users. Let's cancel the change.

Matz.


----------------------------------------
Feature #13083: Regexp#{match,match?} with a nil argument are deprecated and will raise a TypeError in Ruby 3.0
https://bugs.ruby-lang.org/issues/13083#change-82930

* Author: kachick (Kenichi Kamiya)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 2.7
----------------------------------------
Just for consistency

* patch: https://github.com/ruby/ruby/pull/1506
* spec: https://github.com/ruby/spec/pull/380

Currently behaves as ( ruby --version: ruby 2.5.0dev (2016-12-28 trunk 57228) [x86_64-darwin16] )

~~~ ruby
'string'.__send__(:=~, nil) #=> nil
'string'.match(nil)         #=> TypeError: wrong argument type nil (expected Regexp)
'string'.match?(nil)        #=> TypeError: wrong argument type nil (expected Regexp)
:symbol.__send__(:=~, nil)  #=> nil
:symbol.match(nil)          #=> TypeError: wrong argument type nil (expected Regexp)
:symbol.match?(nil)         #=> TypeError: wrong argument type nil (expected Regexp)
/regex/.__send__(:=~, nil)  #=> nil
/regex/.match(nil)          #=> nil
/regex/.match?(nil)         #=> false
~~~


Expected to

~~~ruby
'string'.__send__(:=~, nil) #=> nil
'string'.match(nil)         #=> nil
'string'.match?(nil)        #=> false
:symbol.__send__(:=~, nil)  #=> nil
:symbol.match(nil)          #=> nil
:symbol.match?(nil)         #=> false
/regex/.__send__(:=~, nil)  #=> nil
/regex/.match(nil)          #=> nil
/regex/.match?(nil)         #=> false
~~~



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.