ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:78891] [Ruby trunk Feature#13083] {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
@ 2016-12-28 18:34 ` kachick1
  2016-12-29  0:15 ` [ruby-core:78894] " nobu
                   ` (25 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: kachick1 @ 2016-12-28 18:34 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been reported by Kenichi Kamiya.

----------------------------------------
Feature #13083: {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
https://bugs.ruby-lang.org/issues/13083

* Author: Kenichi Kamiya
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:78894] [Ruby trunk Feature#13083] {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
  2016-12-28 18:34 ` [ruby-core:78891] [Ruby trunk Feature#13083] {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?} kachick1
@ 2016-12-29  0:15 ` nobu
  2017-01-02  0:22 ` [ruby-core:78936] " snood1205
                   ` (24 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: nobu @ 2016-12-29  0:15 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by Nobuyoshi Nakada.

Description updated

----------------------------------------
Feature #13083: {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
https://bugs.ruby-lang.org/issues/13083#change-62307

* Author: Kenichi Kamiya
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:78936] [Ruby trunk Feature#13083] {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
  2016-12-28 18:34 ` [ruby-core:78891] [Ruby trunk Feature#13083] {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?} kachick1
  2016-12-29  0:15 ` [ruby-core:78894] " nobu
@ 2017-01-02  0:22 ` snood1205
  2017-02-22  7:39 ` [ruby-core:79664] " matz
                   ` (23 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: snood1205 @ 2017-01-02  0:22 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by Eli Sadoff.


I think that the way it currently exists is logical. As `=~` is an Object method, it is worth while keeping the more permissible behavior whereas errors should be thrown for `match` and `match?` if `nil` is passed. The change that I would propose would actually to have `Regexp#match` and `Regexp#match?` both raise a type error if `nil` is passed as an argument. The inconsistency seems to be stronger there. 

----------------------------------------
Feature #13083: {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
https://bugs.ruby-lang.org/issues/13083#change-62357

* Author: Kenichi Kamiya
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:79664] [Ruby trunk Feature#13083] {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2017-01-02  0:22 ` [ruby-core:78936] " snood1205
@ 2017-02-22  7:39 ` matz
  2019-10-17 15:24 ` [ruby-core:95396] [Ruby master " zn
                   ` (22 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: matz @ 2017-02-22  7:39 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by Yukihiro Matsumoto.


Those methods (but `=~`) should consistently raise exceptions.

Matz.

----------------------------------------
Feature #13083: {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
https://bugs.ruby-lang.org/issues/13083#change-63083

* Author: Kenichi Kamiya
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:95396] [Ruby master Feature#13083] {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2017-02-22  7:39 ` [ruby-core:79664] " matz
@ 2019-10-17 15:24 ` zn
  2019-10-21  3:41 ` [ruby-core:95448] " zn
                   ` (21 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: zn @ 2019-10-17 15:24 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by znz (Kazuhiro NISHIYAMA).

Status changed from Open to Closed

Merged at commit:2a22a6b2d8465934e75520a7fdcf522d50890caf

----------------------------------------
Feature #13083: {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
https://bugs.ruby-lang.org/issues/13083#change-82109

* Author: kachick (Kenichi Kamiya)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:95448] [Ruby master Feature#13083] {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2019-10-17 15:24 ` [ruby-core:95396] [Ruby master " zn
@ 2019-10-21  3:41 ` zn
  2019-10-26 20:23 ` [ruby-core:95568] " eregontp
                   ` (20 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: zn @ 2019-10-21  3:41 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by znz (Kazuhiro NISHIYAMA).


I heard this change breaks activerecord.

https://twitter.com/shyouhei/status/1186122901667209216
https://twitter.com/shyouhei/status/1186123025604734976
https://github.com/rails/rails/blob/01336b71af6ac798e48101b4ceb2de00397243aa/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb#L52

----------------------------------------
Feature #13083: {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
https://bugs.ruby-lang.org/issues/13083#change-82199

* Author: kachick (Kenichi Kamiya)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:95568] [Ruby master Feature#13083] {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2019-10-21  3:41 ` [ruby-core:95448] " zn
@ 2019-10-26 20:23 ` eregontp
  2019-10-31 22:37 ` [ruby-core:95619] " rafael
                   ` (19 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: eregontp @ 2019-10-26 20:23 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by Eregon (Benoit Daloze).


There are PRs to fix those: https://github.com/rails/rails/pull/37504

----------------------------------------
Feature #13083: {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
https://bugs.ruby-lang.org/issues/13083#change-82349

* Author: kachick (Kenichi Kamiya)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:95619] [Ruby master Feature#13083] {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2019-10-26 20:23 ` [ruby-core:95568] " eregontp
@ 2019-10-31 22:37 ` rafael
  2019-11-01  2:41 ` [ruby-core:95623] " sam.saffron
                   ` (18 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: rafael @ 2019-10-31 22:37 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by rafaelfranca (Rafael França).


I know this change is to make the code consistent but this is a backward incompatible change and I don't think it should be applied to Ruby 2.7 without deprecation. The fact that we need to change Rails and many other gems to make this work is a good indication.

I thought we were avoiding making backward incompatible changes before Ruby 3.0.

----------------------------------------
Feature #13083: {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
https://bugs.ruby-lang.org/issues/13083#change-82410

* Author: kachick (Kenichi Kamiya)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:95623] [Ruby master Feature#13083] {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (7 preceding siblings ...)
  2019-10-31 22:37 ` [ruby-core:95619] " rafael
@ 2019-11-01  2:41 ` sam.saffron
  2019-11-01  2:46 ` [ruby-core:95625] " shyouhei
                   ` (17 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: sam.saffron @ 2019-11-01  2:41 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by sam.saffron (Sam Saffron).


I am 100% with Rafael here, this is a very risky change, Rails and Sprockets are only a couple of projects, there will be tons of stuff that will not be caught.

Why not deprecate this for now and then next release it can be removed? 

----------------------------------------
Feature #13083: {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
https://bugs.ruby-lang.org/issues/13083#change-82413

* Author: kachick (Kenichi Kamiya)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:95625] [Ruby master Feature#13083] {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (8 preceding siblings ...)
  2019-11-01  2:41 ` [ruby-core:95623] " sam.saffron
@ 2019-11-01  2:46 ` shyouhei
  2019-11-01  3:44 ` [ruby-core:95628] " shugo
                   ` (16 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: shyouhei @ 2019-11-01  2:46 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by shyouhei (Shyouhei Urabe).


+1 for deprecation.  The removal is too harsh.

----------------------------------------
Feature #13083: {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
https://bugs.ruby-lang.org/issues/13083#change-82415

* Author: kachick (Kenichi Kamiya)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:95628] [Ruby master Feature#13083] {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (9 preceding siblings ...)
  2019-11-01  2:46 ` [ruby-core:95625] " shyouhei
@ 2019-11-01  3:44 ` shugo
  2019-11-01  8:51 ` [ruby-core:95632] " matz
                   ` (15 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: shugo @ 2019-11-01  3:44 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by shugo (Shugo Maeda).


+1 for deprecation too.  My text editor had been broken by this change, and Vim was needed to fix it.

----------------------------------------
Feature #13083: {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
https://bugs.ruby-lang.org/issues/13083#change-82416

* Author: kachick (Kenichi Kamiya)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:95632] [Ruby master Feature#13083] {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (10 preceding siblings ...)
  2019-11-01  3:44 ` [ruby-core:95628] " shugo
@ 2019-11-01  8:51 ` matz
  2019-11-01 16:05 ` [ruby-core:95636] " rafael
                   ` (14 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: matz @ 2019-11-01  8:51 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by matz (Yukihiro Matsumoto).


Thank you for the input. If you can provide a more detailed situation, it would be better.

Matz.


----------------------------------------
Feature #13083: {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
https://bugs.ruby-lang.org/issues/13083#change-82419

* Author: kachick (Kenichi Kamiya)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:95636] [Ruby master Feature#13083] {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (11 preceding siblings ...)
  2019-11-01  8:51 ` [ruby-core:95632] " matz
@ 2019-11-01 16:05 ` rafael
  2019-11-01 18:02 ` [ruby-core:95640] " eregontp
                   ` (13 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: rafael @ 2019-11-01 16:05 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by rafaelfranca (Rafael França).


The detailed situation.

Rails and other libraries and codebases rely on `/regex/.match?(nil)` to return false. This change is making that method to raise an error in that situation.

Changing this behavior on Ruby 2.7 means that applications will break because of this change.

This change also have dubious value. While it makes things consistent now it require the callers to do one more check.

Code that before was:

     /foo/.match?(some_variable)

Need to become:

    some_variable && /foo/.match?(some_variable)

or

    /foo/.match?(some_variable) unless some_variable

If you ask me, I believe this change is good, but it doesn't require a breaking change. We can deprecate the old behavior and then in a next version remove it.

The codebases can change their code, of course, but so they can change for any breaking change in Ruby. If we are being careful to not introduce breaking changes in Ruby, this change should also falls in that category in my opinion. If we are ok with this breaking change, why not with others like frozen string as default? Both change will require changes to codebases and both changes have dubious value.

----------------------------------------
Feature #13083: {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
https://bugs.ruby-lang.org/issues/13083#change-82424

* Author: kachick (Kenichi Kamiya)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:95640] [Ruby master Feature#13083] {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (12 preceding siblings ...)
  2019-11-01 16:05 ` [ruby-core:95636] " rafael
@ 2019-11-01 18:02 ` eregontp
  2019-11-01 19:20 ` [ruby-core:95642] [Ruby master Feature#13083] {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?} since ruby 3.0 kachick1
                   ` (12 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: eregontp @ 2019-11-01 18:02 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by Eregon (Benoit Daloze).


I think everyone agrees this is too breaking (just look at how many call sites need to be changed in Rails and other gems),
and it's very easy to deprecate the old behavior by warning when passing `nil` in Ruby 2.7.

The only question for me is: who will change it to a deprecation?

----------------------------------------
Feature #13083: {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?}
https://bugs.ruby-lang.org/issues/13083#change-82428

* Author: kachick (Kenichi Kamiya)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:95642] [Ruby master Feature#13083] {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?} since ruby 3.0
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (13 preceding siblings ...)
  2019-11-01 18:02 ` [ruby-core:95640] " eregontp
@ 2019-11-01 19:20 ` kachick1
  2019-11-03  0:35 ` [ruby-core:95656] " shugo
                   ` (11 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: kachick1 @ 2019-11-01 19:20 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by kachick (Kenichi Kamiya).

Subject changed from {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?} to {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?} since ruby 3.0

How about https://github.com/ruby/ruby/pull/2637? 

----------------------------------------
Feature #13083: {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?} since ruby 3.0
https://bugs.ruby-lang.org/issues/13083#change-82430

* Author: kachick (Kenichi Kamiya)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:95656] [Ruby master Feature#13083] {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?} since ruby 3.0
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (14 preceding siblings ...)
  2019-11-01 19:20 ` [ruby-core:95642] [Ruby master Feature#13083] {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?} since ruby 3.0 kachick1
@ 2019-11-03  0:35 ` shugo
  2019-11-03 10:18 ` [ruby-core:95657] [Ruby master Feature#13083] Regexp#{match, match?} with a nil argument are deprecated and will raise a TypeError in Ruby 3.0 eregontp
                   ` (10 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: shugo @ 2019-11-03  0:35 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by shugo (Shugo Maeda).


matz (Yukihiro Matsumoto) wrote:
> Thank you for the input. If you can provide a more detailed situation, it would be better.

My situation is the same as Rafael's, and I fixed my code using the safe navigation operator:

  https://github.com/shugo/textbringer/commit/c859d13

Code like `/regex/ =~ str` has often been used when `str` may be `nil`, and such code has been rewritten using Regexp#match? after Ruby 2.4.
This change will break all such code.


----------------------------------------
Feature #13083: {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?} since ruby 3.0
https://bugs.ruby-lang.org/issues/13083#change-82444

* Author: kachick (Kenichi Kamiya)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:95657] [Ruby master Feature#13083] Regexp#{match, match?} with a nil argument are deprecated and will raise a TypeError in Ruby 3.0
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (15 preceding siblings ...)
  2019-11-03  0:35 ` [ruby-core:95656] " shugo
@ 2019-11-03 10:18 ` eregontp
  2019-11-03 10:31 ` [ruby-core:95658] " eregontp
                   ` (9 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: eregontp @ 2019-11-03 10:18 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by Eregon (Benoit Daloze).


kachick (Kenichi Kamiya) wrote:
> How about https://github.com/ruby/ruby/pull/2637?

I merged that PR, thank you.
Regexp#{match,match?} with a nil argument now just warn.

The plan is then to make them raise TypeError in Ruby 3.0.

----------------------------------------
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-82446

* Author: kachick (Kenichi Kamiya)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:95658] [Ruby master Feature#13083] Regexp#{match, match?} with a nil argument are deprecated and will raise a TypeError in Ruby 3.0
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (16 preceding siblings ...)
  2019-11-03 10:18 ` [ruby-core:95657] [Ruby master Feature#13083] Regexp#{match, match?} with a nil argument are deprecated and will raise a TypeError in Ruby 3.0 eregontp
@ 2019-11-03 10:31 ` eregontp
  2019-11-04 13:51 ` [ruby-core:95666] " daniel
                   ` (8 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: eregontp @ 2019-11-03 10:31 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by Eregon (Benoit Daloze).


shugo (Shugo Maeda) wrote:
> Code like `/regex/ =~ str` has often been used when `str` may be `nil`, and such code has been rewritten using Regexp#match? after Ruby 2.4.
> This change will break all such code.

That's a good point.
We can still discuss on this ticket whether we should change behavior at all,
but I think so far everyone was fine with deprecation (warning) and then removal later on, so I merged the PR

----------------------------------------
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-82447

* Author: kachick (Kenichi Kamiya)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:95666] [Ruby master Feature#13083] Regexp#{match, match?} with a nil argument are deprecated and will raise a TypeError in Ruby 3.0
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (17 preceding siblings ...)
  2019-11-03 10:31 ` [ruby-core:95658] " eregontp
@ 2019-11-04 13:51 ` daniel
  2019-11-05  3:30 ` [ruby-core:95685] " shugo
                   ` (7 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: daniel @ 2019-11-04 13:51 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by Dan0042 (Daniel DeLorme).


Is there a benefit to the change apart from consistency? A concrete benefit I mean.

----------------------------------------
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-82452

* Author: kachick (Kenichi Kamiya)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:95685] [Ruby master Feature#13083] Regexp#{match, match?} with a nil argument are deprecated and will raise a TypeError in Ruby 3.0
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (18 preceding siblings ...)
  2019-11-04 13:51 ` [ruby-core:95666] " daniel
@ 2019-11-05  3:30 ` shugo
  2019-11-05  9:23 ` [ruby-core:95691] " naruse
                   ` (6 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: shugo @ 2019-11-05  3:30 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by shugo (Shugo Maeda).

Status changed from Closed to Open

Eregon (Benoit Daloze) wrote:
> shugo (Shugo Maeda) wrote:
> > Code like `/regex/ =~ str` has often been used when `str` may be `nil`, and such code has been rewritten using Regexp#match? after Ruby 2.4.
> > This change will break all such code.
> 
> That's a good point.
> We can still discuss on this ticket whether we should change behavior at all,
> but I think so far everyone was fine with deprecation (warning) and then removal later on, so I merged the PR

Thank you.
I reopen this issue for further discussion.

----------------------------------------
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-82473

* Author: kachick (Kenichi Kamiya)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:95691] [Ruby master Feature#13083] Regexp#{match, match?} with a nil argument are deprecated and will raise a TypeError in Ruby 3.0
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (19 preceding siblings ...)
  2019-11-05  3:30 ` [ruby-core:95685] " shugo
@ 2019-11-05  9:23 ` naruse
  2019-11-07 18:32 ` [ruby-core:95747] " eregontp
                   ` (5 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: naruse @ 2019-11-05  9:23 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by naruse (Yui NARUSE).

Target version set to 2.7

NOTE: warning message should be improved if this is deprecated before 2.7.0.

----------------------------------------
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-82479

* 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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:95747] [Ruby master Feature#13083] Regexp#{match, match?} with a nil argument are deprecated and will raise a TypeError in Ruby 3.0
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (20 preceding siblings ...)
  2019-11-05  9:23 ` [ruby-core:95691] " naruse
@ 2019-11-07 18:32 ` eregontp
  2019-11-14 16:14 ` [ruby-core:95850] " shevegen
                   ` (4 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: eregontp @ 2019-11-07 18:32 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by Eregon (Benoit Daloze).


Dan0042 (Daniel DeLorme) wrote:
> Is there a benefit to the change apart from consistency? A concrete benefit I mean.

I think consistency is good here, and also it seems to me `regexp.match?(s)` with `s` being `nil` could actually catch bugs where `s` is not expected to be `nil`.
It seems rather odd to me to validate some input and even accept `nil` as an "OK" value to match against a Regexp.
`nil` means typically "missing value" in such a case, and often deserves its own behavior (e.g., could be empty string is not provided, could be an error, could be special behavior just for `nil`, could be some non-empty default String which would help readability).

In the Rails PR I noticed a case that doesn't but is fairly close to end up in `nil.to_i`, which would likely be a bug/unintended:
https://github.com/rails/rails/pull/37504/files#diff-c226a4680f86689c3c170d4bc5911e96

----------------------------------------
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-82564

* 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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:95850] [Ruby master Feature#13083] Regexp#{match, match?} with a nil argument are deprecated and will raise a TypeError in Ruby 3.0
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (21 preceding siblings ...)
  2019-11-07 18:32 ` [ruby-core:95747] " eregontp
@ 2019-11-14 16:14 ` shevegen
  2019-11-18 13:36 ` [ruby-core:95878] " knu
                   ` (3 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: shevegen @ 2019-11-14 16:14 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by shevegen (Robert A. Heiler).


Dan0042 wrote:

> Is there a benefit to the change apart from consistency? A concrete benefit I mean.

This is only one point of view.

Sometimes there are "wrong" use cases or use cases that were not anticipated by the core team. In
my opinion, whenever possible, it is best to encourage consistency and clarity, as close as possible
to matz' original design consideration (because I think that this way people will not be confused
as much; remember the confusion from people thinking that there is a singular "principle of least
surprise", but then everyone using their own definition for that - that can not work).

To the suggestion itself: I have no particular pro or con opinion either way. None of the code that
I use would be affected by the change, should it come. Ruby 3.0 is not so far away so there may
be lots of changes coming to ruby past 3.0 anyway. :)

----------------------------------------
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-82684

* 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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:95878] [Ruby master Feature#13083] Regexp#{match, match?} with a nil argument are deprecated and will raise a TypeError in Ruby 3.0
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (22 preceding siblings ...)
  2019-11-14 16:14 ` [ruby-core:95850] " shevegen
@ 2019-11-18 13:36 ` knu
  2019-11-18 18:01 ` [ruby-core:95879] " eregontp
                   ` (2 subsequent siblings)
  26 siblings, 0 replies; 27+ messages in thread
From: knu @ 2019-11-18 13:36 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by knu (Akinori MUSHA).


I'm a bit surprised and confused.  The change that has been made is not what this issue was originally about, and actually the opposite, I think.

I believe many of us have got used to the original behavior, that is, methods of a Regexp object work permissively and accepts nil, and we know we've migrated many pieces of code from `/re/ =~ nilable` / `/re/ === nilable` to `/re/.match?(nilable)` for the sake of performance and readability just as shugo says above.

Can't we reconsider this?  Or we'll be doomed to back out all those changes we believed to improve performance.

----------------------------------------
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-82715

* 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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:95879] [Ruby master Feature#13083] Regexp#{match, match?} with a nil argument are deprecated and will raise a TypeError in Ruby 3.0
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (23 preceding siblings ...)
  2019-11-18 13:36 ` [ruby-core:95878] " knu
@ 2019-11-18 18:01 ` eregontp
  2019-12-03  8:57 ` [ruby-core:96068] " naruse
  2019-12-03 13:34 ` [ruby-core:96081] " matz
  26 siblings, 0 replies; 27+ messages in thread
From: eregontp @ 2019-11-18 18:01 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by Eregon (Benoit Daloze).


knu (Akinori MUSHA) wrote:
> I'm a bit surprised and confused.  The change that has been made is not what this issue was originally about, and actually the opposite, I think.

Per matz's decision: https://bugs.ruby-lang.org/issues/13083#note-3
I renamed the issue in https://bugs.ruby-lang.org/issues/13083#note-16 to match the current change.
Now it's just a deprecation warning.

> I believe many of us have got used to the original behavior, that is, methods of a Regexp object work permissively and accept nil, and we know we've migrated many pieces of code from `/re/ =~ nilable` / `/re/ === nilable` to `/re/.match?(nilable)` for the sake of performance and readability just as shugo said above.
> 
> Can't we reconsider this?  Or we'll be doomed to back out all those changes we believed to improve performance.

`nilable&.match?(/re/)` would be an easy way to rewrite those cases, no?

@matz and others: what do you think, should we make `Regexp#{match,match?}` consistent and not accept `nil` or accept them as special-case to match the =~ and === operators?

----------------------------------------
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-82716

* 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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [ruby-core:96068] [Ruby master Feature#13083] Regexp#{match, match?} with a nil argument are deprecated and will raise a TypeError in Ruby 3.0
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (24 preceding siblings ...)
  2019-11-18 18:01 ` [ruby-core:95879] " eregontp
@ 2019-12-03  8:57 ` naruse
  2019-12-03 13:34 ` [ruby-core:96081] " matz
  26 siblings, 0 replies; 27+ messages in thread
From: naruse @ 2019-12-03  8:57 UTC (permalink / raw)
  To: ruby-core

Issue #13083 has been updated by naruse (Yui NARUSE).


Eregon (Benoit Daloze) wrote:
> > I believe many of us have got used to the original behavior, that is, methods of a Regexp object work permissively and accept nil, and we know we've migrated many pieces of code from `/re/ =~ nilable` / `/re/ === nilable` to `/re/.match?(nilable)` for the sake of performance and readability just as shugo said above.
> > 
> > Can't we reconsider this?  Or we'll be doomed to back out all those changes we believed to improve performance.
> 
> `nilable&.match?(/re/)` would be an easy way to rewrite those cases, no?
> 
> @matz and others: what do you think, should we make `Regexp#{match,match?}` consistent and not accept `nil` or accept them as special-case to match the =~ and === operators?

I also received the same feedback from Rails people.
`nilable&.match?(/re/)` sounds a reasonable option, but why do we provide a such pitfall?

----------------------------------------
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-82917

* 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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [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
       [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
                   ` (25 preceding siblings ...)
  2019-12-03  8:57 ` [ruby-core:96068] " naruse
@ 2019-12-03 13:34 ` matz
  26 siblings, 0 replies; 27+ messages in thread
From: matz @ 2019-12-03 13:34 UTC (permalink / raw)
  To: ruby-core

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/

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2019-12-03 13:34 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-13083.20161228183444@ruby-lang.org>
2016-12-28 18:34 ` [ruby-core:78891] [Ruby trunk Feature#13083] {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?} kachick1
2016-12-29  0:15 ` [ruby-core:78894] " nobu
2017-01-02  0:22 ` [ruby-core:78936] " snood1205
2017-02-22  7:39 ` [ruby-core:79664] " matz
2019-10-17 15:24 ` [ruby-core:95396] [Ruby master " zn
2019-10-21  3:41 ` [ruby-core:95448] " zn
2019-10-26 20:23 ` [ruby-core:95568] " eregontp
2019-10-31 22:37 ` [ruby-core:95619] " rafael
2019-11-01  2:41 ` [ruby-core:95623] " sam.saffron
2019-11-01  2:46 ` [ruby-core:95625] " shyouhei
2019-11-01  3:44 ` [ruby-core:95628] " shugo
2019-11-01  8:51 ` [ruby-core:95632] " matz
2019-11-01 16:05 ` [ruby-core:95636] " rafael
2019-11-01 18:02 ` [ruby-core:95640] " eregontp
2019-11-01 19:20 ` [ruby-core:95642] [Ruby master Feature#13083] {String|Symbol}#match{?} with nil returns falsy as Regexp#match{?} since ruby 3.0 kachick1
2019-11-03  0:35 ` [ruby-core:95656] " shugo
2019-11-03 10:18 ` [ruby-core:95657] [Ruby master Feature#13083] Regexp#{match, match?} with a nil argument are deprecated and will raise a TypeError in Ruby 3.0 eregontp
2019-11-03 10:31 ` [ruby-core:95658] " eregontp
2019-11-04 13:51 ` [ruby-core:95666] " daniel
2019-11-05  3:30 ` [ruby-core:95685] " shugo
2019-11-05  9:23 ` [ruby-core:95691] " naruse
2019-11-07 18:32 ` [ruby-core:95747] " eregontp
2019-11-14 16:14 ` [ruby-core:95850] " shevegen
2019-11-18 13:36 ` [ruby-core:95878] " knu
2019-11-18 18:01 ` [ruby-core:95879] " eregontp
2019-12-03  8:57 ` [ruby-core:96068] " naruse
2019-12-03 13:34 ` [ruby-core:96081] " matz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).