* [ruby-core:67656] [ruby-trunk - Bug #10753] [Open] Refined class returns unexpected value when call public_method_defined?, protected_method_defined?, private_method_defined?
[not found] <redmine.issue-10753.20150117184431@ruby-lang.org>
@ 2015-01-17 18:44 ` hanachin
2015-01-17 18:47 ` [ruby-core:67657] [ruby-trunk - Bug #10753] " hanachin
` (4 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: hanachin @ 2015-01-17 18:44 UTC (permalink / raw
To: ruby-core
Issue #10753 has been reported by Seiei Higa.
----------------------------------------
Bug #10753: Refined class returns unexpected value when call public_method_defined?, protected_method_defined?, private_method_defined?
https://bugs.ruby-lang.org/issues/10753
* Author: Seiei Higa
* Status: Open
* Priority: Normal
* Assignee:
* ruby -v: ruby 2.3.0dev (2015-01-18 trunk 49312) [x86_64-darwin14]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
When I call `public_method_defined?` or `protected_method_defined?` or `private_method_defined?` methods of the class,
the result is not expected if the method is refined.
i confirmed with following example programs in ruby-trunk, 2.0.0-p598, 2.1.5, 2.2.0
examples
=======
bug_refined_method_defined.rb
-----------------------------
``` ruby
c = Class.new do
def refined_public; end
def refined_protected; end
def refined_private; end
public :refined_public
protected :refined_protected
private :refined_private
end
m = Module.new do
refine(c) do
def refined_public; end
def refined_protected; end
def refined_private; end
public :refined_public
protected :refined_protected
private :refined_private
end
end
using m
predicate_methods = %i(
method_defined?
public_method_defined?
protected_method_defined?
private_method_defined?
)
methods = %i(
refined_public
refined_protected
refined_private
)
predicate_methods.each do |predicate_method|
puts predicate_method
puts '-' * 8
methods.each do |method|
puts "#{predicate_method}(#{method}) # => #{c.send(predicate_method, method)}"
end
puts
end
```
expected:
---------
``` console
$ ./ruby --disable-gems bug_refined_method_defined.rb
method_defined?
--------
method_defined?(refined_public) # => true
method_defined?(refined_protected) # => true
method_defined?(refined_private) # => false
public_method_defined?
--------
public_method_defined?(refined_public) # => true
public_method_defined?(refined_protected) # => false
public_method_defined?(refined_private) # => false
protected_method_defined?
--------
protected_method_defined?(refined_public) # => false
protected_method_defined?(refined_protected) # => true
protected_method_defined?(refined_private) # => false
private_method_defined?
--------
private_method_defined?(refined_public) # => false
private_method_defined?(refined_protected) # => false
private_method_defined?(refined_private) # => true
```
actual:
-------
``` console
$ ./ruby --disable-gems bug_refined_method_defined.rb
method_defined?
--------
method_defined?(refined_public) # => true
method_defined?(refined_protected) # => true
method_defined?(refined_private) # => false
public_method_defined?
--------
public_method_defined?(refined_public) # => true
public_method_defined?(refined_protected) # => true
public_method_defined?(refined_private) # => true
protected_method_defined?
--------
protected_method_defined?(refined_public) # => false
protected_method_defined?(refined_protected) # => false
protected_method_defined?(refined_private) # => false
private_method_defined?
--------
private_method_defined?(refined_public) # => false
private_method_defined?(refined_protected) # => false
private_method_defined?(refined_private) # => false
```
bug_undefined_refined_method_defined.rb
=======================================
``` ruby
c = Class.new
m = Module.new do
refine(c) do
def undefined_refined_public; end
def undefined_refined_protected; end
def undefined_refined_private; end
public :undefined_refined_public
protected :undefined_refined_protected
private :undefined_refined_private
end
end
using m
predicate_methods = %i(
method_defined?
public_method_defined?
protected_method_defined?
private_method_defined?
)
methods = %i(
undefined_refined_public
undefined_refined_protected
undefined_refined_private
)
predicate_methods.each do |predicate_method|
puts predicate_method
puts '-' * 8
methods.each do |method|
puts "#{predicate_method}(#{method}) # => #{c.send(predicate_method, method)}"
end
puts
end
```
expected:
---------
``` console
$ ./ruby --disable-gems bug_undefined_refined_method_defined.rb
method_defined?
--------
method_defined?(undefined_refined_public) # => false
method_defined?(undefined_refined_protected) # => false
method_defined?(undefined_refined_private) # => false
public_method_defined?
--------
public_method_defined?(undefined_refined_public) # => false
public_method_defined?(undefined_refined_protected) # => false
public_method_defined?(undefined_refined_private) # => false
protected_method_defined?
--------
protected_method_defined?(undefined_refined_public) # => false
protected_method_defined?(undefined_refined_protected) # => false
protected_method_defined?(undefined_refined_private) # => false
private_method_defined?
--------
private_method_defined?(undefined_refined_public) # => false
private_method_defined?(undefined_refined_protected) # => false
private_method_defined?(undefined_refined_private) # => false
```
actual:
-------
``` console
$ ./ruby --disable-gems bug_undefined_refined_method_defined.rb
method_defined?
--------
method_defined?(undefined_refined_public) # => false
method_defined?(undefined_refined_protected) # => false
method_defined?(undefined_refined_private) # => false
public_method_defined?
--------
public_method_defined?(undefined_refined_public) # => true
public_method_defined?(undefined_refined_protected) # => true
public_method_defined?(undefined_refined_private) # => true
protected_method_defined?
--------
protected_method_defined?(undefined_refined_public) # => false
protected_method_defined?(undefined_refined_protected) # => false
protected_method_defined?(undefined_refined_private) # => false
private_method_defined?
--------
private_method_defined?(undefined_refined_public) # => false
private_method_defined?(undefined_refined_protected) # => false
private_method_defined?(undefined_refined_private) # => false
```
---Files--------------------------------
bug_refined_method_defined.rb (825 Bytes)
bug_undefined_refined_method_defined.rb (740 Bytes)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 6+ messages in thread
* [ruby-core:67657] [ruby-trunk - Bug #10753] Refined class returns unexpected value when call public_method_defined?, protected_method_defined?, private_method_defined?
[not found] <redmine.issue-10753.20150117184431@ruby-lang.org>
2015-01-17 18:44 ` [ruby-core:67656] [ruby-trunk - Bug #10753] [Open] Refined class returns unexpected value when call public_method_defined?, protected_method_defined?, private_method_defined? hanachin
@ 2015-01-17 18:47 ` hanachin
2015-01-18 6:57 ` [ruby-core:67672] [ruby-trunk - Bug #10753] [Closed] " nobu
` (3 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: hanachin @ 2015-01-17 18:47 UTC (permalink / raw
To: ruby-core
Issue #10753 has been updated by Seiei Higa.
File 0001-vm_method.c-method-defined-should-not-use-refinement.patch added
I create a patch for this.
----------------------------------------
Bug #10753: Refined class returns unexpected value when call public_method_defined?, protected_method_defined?, private_method_defined?
https://bugs.ruby-lang.org/issues/10753#change-51075
* Author: Seiei Higa
* Status: Open
* Priority: Normal
* Assignee:
* ruby -v: ruby 2.3.0dev (2015-01-18 trunk 49312) [x86_64-darwin14]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
When I call `public_method_defined?` or `protected_method_defined?` or `private_method_defined?` methods of the class,
the result is not expected if the method is refined.
i confirmed with following example programs in ruby-trunk, 2.0.0-p598, 2.1.5, 2.2.0
examples
=======
bug_refined_method_defined.rb
-----------------------------
``` ruby
c = Class.new do
def refined_public; end
def refined_protected; end
def refined_private; end
public :refined_public
protected :refined_protected
private :refined_private
end
m = Module.new do
refine(c) do
def refined_public; end
def refined_protected; end
def refined_private; end
public :refined_public
protected :refined_protected
private :refined_private
end
end
using m
predicate_methods = %i(
method_defined?
public_method_defined?
protected_method_defined?
private_method_defined?
)
methods = %i(
refined_public
refined_protected
refined_private
)
predicate_methods.each do |predicate_method|
puts predicate_method
puts '-' * 8
methods.each do |method|
puts "#{predicate_method}(#{method}) # => #{c.send(predicate_method, method)}"
end
puts
end
```
expected:
---------
``` console
$ ./ruby --disable-gems bug_refined_method_defined.rb
method_defined?
--------
method_defined?(refined_public) # => true
method_defined?(refined_protected) # => true
method_defined?(refined_private) # => false
public_method_defined?
--------
public_method_defined?(refined_public) # => true
public_method_defined?(refined_protected) # => false
public_method_defined?(refined_private) # => false
protected_method_defined?
--------
protected_method_defined?(refined_public) # => false
protected_method_defined?(refined_protected) # => true
protected_method_defined?(refined_private) # => false
private_method_defined?
--------
private_method_defined?(refined_public) # => false
private_method_defined?(refined_protected) # => false
private_method_defined?(refined_private) # => true
```
actual:
-------
``` console
$ ./ruby --disable-gems bug_refined_method_defined.rb
method_defined?
--------
method_defined?(refined_public) # => true
method_defined?(refined_protected) # => true
method_defined?(refined_private) # => false
public_method_defined?
--------
public_method_defined?(refined_public) # => true
public_method_defined?(refined_protected) # => true
public_method_defined?(refined_private) # => true
protected_method_defined?
--------
protected_method_defined?(refined_public) # => false
protected_method_defined?(refined_protected) # => false
protected_method_defined?(refined_private) # => false
private_method_defined?
--------
private_method_defined?(refined_public) # => false
private_method_defined?(refined_protected) # => false
private_method_defined?(refined_private) # => false
```
bug_undefined_refined_method_defined.rb
=======================================
``` ruby
c = Class.new
m = Module.new do
refine(c) do
def undefined_refined_public; end
def undefined_refined_protected; end
def undefined_refined_private; end
public :undefined_refined_public
protected :undefined_refined_protected
private :undefined_refined_private
end
end
using m
predicate_methods = %i(
method_defined?
public_method_defined?
protected_method_defined?
private_method_defined?
)
methods = %i(
undefined_refined_public
undefined_refined_protected
undefined_refined_private
)
predicate_methods.each do |predicate_method|
puts predicate_method
puts '-' * 8
methods.each do |method|
puts "#{predicate_method}(#{method}) # => #{c.send(predicate_method, method)}"
end
puts
end
```
expected:
---------
``` console
$ ./ruby --disable-gems bug_undefined_refined_method_defined.rb
method_defined?
--------
method_defined?(undefined_refined_public) # => false
method_defined?(undefined_refined_protected) # => false
method_defined?(undefined_refined_private) # => false
public_method_defined?
--------
public_method_defined?(undefined_refined_public) # => false
public_method_defined?(undefined_refined_protected) # => false
public_method_defined?(undefined_refined_private) # => false
protected_method_defined?
--------
protected_method_defined?(undefined_refined_public) # => false
protected_method_defined?(undefined_refined_protected) # => false
protected_method_defined?(undefined_refined_private) # => false
private_method_defined?
--------
private_method_defined?(undefined_refined_public) # => false
private_method_defined?(undefined_refined_protected) # => false
private_method_defined?(undefined_refined_private) # => false
```
actual:
-------
``` console
$ ./ruby --disable-gems bug_undefined_refined_method_defined.rb
method_defined?
--------
method_defined?(undefined_refined_public) # => false
method_defined?(undefined_refined_protected) # => false
method_defined?(undefined_refined_private) # => false
public_method_defined?
--------
public_method_defined?(undefined_refined_public) # => true
public_method_defined?(undefined_refined_protected) # => true
public_method_defined?(undefined_refined_private) # => true
protected_method_defined?
--------
protected_method_defined?(undefined_refined_public) # => false
protected_method_defined?(undefined_refined_protected) # => false
protected_method_defined?(undefined_refined_private) # => false
private_method_defined?
--------
private_method_defined?(undefined_refined_public) # => false
private_method_defined?(undefined_refined_protected) # => false
private_method_defined?(undefined_refined_private) # => false
```
---Files--------------------------------
bug_refined_method_defined.rb (825 Bytes)
bug_undefined_refined_method_defined.rb (740 Bytes)
0001-vm_method.c-method-defined-should-not-use-refinement.patch (3.95 KB)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 6+ messages in thread
* [ruby-core:67672] [ruby-trunk - Bug #10753] [Closed] Refined class returns unexpected value when call public_method_defined?, protected_method_defined?, private_method_defined?
[not found] <redmine.issue-10753.20150117184431@ruby-lang.org>
2015-01-17 18:44 ` [ruby-core:67656] [ruby-trunk - Bug #10753] [Open] Refined class returns unexpected value when call public_method_defined?, protected_method_defined?, private_method_defined? hanachin
2015-01-17 18:47 ` [ruby-core:67657] [ruby-trunk - Bug #10753] " hanachin
@ 2015-01-18 6:57 ` nobu
2015-01-26 7:30 ` [ruby-core:67812] [ruby-trunk - Bug #10753] " naruse
` (2 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: nobu @ 2015-01-18 6:57 UTC (permalink / raw
To: ruby-core
Issue #10753 has been updated by Nobuyoshi Nakada.
Status changed from Open to Closed
% Done changed from 0 to 100
Applied in changeset r49322.
----------
vm_method.c: method defined should not use refinements.
* vm_method.c (check_definition): Module#public_method_defined?,
Module#private_method_defined?, Module#protected_method_defined?
should not use refinements. [ruby-core:67656] [Bug #10753]
----------------------------------------
Bug #10753: Refined class returns unexpected value when call public_method_defined?, protected_method_defined?, private_method_defined?
https://bugs.ruby-lang.org/issues/10753#change-51087
* Author: Seiei Higa
* Status: Closed
* Priority: Normal
* Assignee:
* ruby -v: ruby 2.3.0dev (2015-01-18 trunk 49312) [x86_64-darwin14]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
When I call `public_method_defined?` or `protected_method_defined?` or `private_method_defined?` methods of the class,
the result is not expected if the method is refined.
i confirmed with following example programs in ruby-trunk, 2.0.0-p598, 2.1.5, 2.2.0
examples
=======
bug_refined_method_defined.rb
-----------------------------
``` ruby
c = Class.new do
def refined_public; end
def refined_protected; end
def refined_private; end
public :refined_public
protected :refined_protected
private :refined_private
end
m = Module.new do
refine(c) do
def refined_public; end
def refined_protected; end
def refined_private; end
public :refined_public
protected :refined_protected
private :refined_private
end
end
using m
predicate_methods = %i(
method_defined?
public_method_defined?
protected_method_defined?
private_method_defined?
)
methods = %i(
refined_public
refined_protected
refined_private
)
predicate_methods.each do |predicate_method|
puts predicate_method
puts '-' * 8
methods.each do |method|
puts "#{predicate_method}(#{method}) # => #{c.send(predicate_method, method)}"
end
puts
end
```
expected:
---------
``` console
$ ./ruby --disable-gems bug_refined_method_defined.rb
method_defined?
--------
method_defined?(refined_public) # => true
method_defined?(refined_protected) # => true
method_defined?(refined_private) # => false
public_method_defined?
--------
public_method_defined?(refined_public) # => true
public_method_defined?(refined_protected) # => false
public_method_defined?(refined_private) # => false
protected_method_defined?
--------
protected_method_defined?(refined_public) # => false
protected_method_defined?(refined_protected) # => true
protected_method_defined?(refined_private) # => false
private_method_defined?
--------
private_method_defined?(refined_public) # => false
private_method_defined?(refined_protected) # => false
private_method_defined?(refined_private) # => true
```
actual:
-------
``` console
$ ./ruby --disable-gems bug_refined_method_defined.rb
method_defined?
--------
method_defined?(refined_public) # => true
method_defined?(refined_protected) # => true
method_defined?(refined_private) # => false
public_method_defined?
--------
public_method_defined?(refined_public) # => true
public_method_defined?(refined_protected) # => true
public_method_defined?(refined_private) # => true
protected_method_defined?
--------
protected_method_defined?(refined_public) # => false
protected_method_defined?(refined_protected) # => false
protected_method_defined?(refined_private) # => false
private_method_defined?
--------
private_method_defined?(refined_public) # => false
private_method_defined?(refined_protected) # => false
private_method_defined?(refined_private) # => false
```
bug_undefined_refined_method_defined.rb
=======================================
``` ruby
c = Class.new
m = Module.new do
refine(c) do
def undefined_refined_public; end
def undefined_refined_protected; end
def undefined_refined_private; end
public :undefined_refined_public
protected :undefined_refined_protected
private :undefined_refined_private
end
end
using m
predicate_methods = %i(
method_defined?
public_method_defined?
protected_method_defined?
private_method_defined?
)
methods = %i(
undefined_refined_public
undefined_refined_protected
undefined_refined_private
)
predicate_methods.each do |predicate_method|
puts predicate_method
puts '-' * 8
methods.each do |method|
puts "#{predicate_method}(#{method}) # => #{c.send(predicate_method, method)}"
end
puts
end
```
expected:
---------
``` console
$ ./ruby --disable-gems bug_undefined_refined_method_defined.rb
method_defined?
--------
method_defined?(undefined_refined_public) # => false
method_defined?(undefined_refined_protected) # => false
method_defined?(undefined_refined_private) # => false
public_method_defined?
--------
public_method_defined?(undefined_refined_public) # => false
public_method_defined?(undefined_refined_protected) # => false
public_method_defined?(undefined_refined_private) # => false
protected_method_defined?
--------
protected_method_defined?(undefined_refined_public) # => false
protected_method_defined?(undefined_refined_protected) # => false
protected_method_defined?(undefined_refined_private) # => false
private_method_defined?
--------
private_method_defined?(undefined_refined_public) # => false
private_method_defined?(undefined_refined_protected) # => false
private_method_defined?(undefined_refined_private) # => false
```
actual:
-------
``` console
$ ./ruby --disable-gems bug_undefined_refined_method_defined.rb
method_defined?
--------
method_defined?(undefined_refined_public) # => false
method_defined?(undefined_refined_protected) # => false
method_defined?(undefined_refined_private) # => false
public_method_defined?
--------
public_method_defined?(undefined_refined_public) # => true
public_method_defined?(undefined_refined_protected) # => true
public_method_defined?(undefined_refined_private) # => true
protected_method_defined?
--------
protected_method_defined?(undefined_refined_public) # => false
protected_method_defined?(undefined_refined_protected) # => false
protected_method_defined?(undefined_refined_private) # => false
private_method_defined?
--------
private_method_defined?(undefined_refined_public) # => false
private_method_defined?(undefined_refined_protected) # => false
private_method_defined?(undefined_refined_private) # => false
```
---Files--------------------------------
bug_refined_method_defined.rb (825 Bytes)
bug_undefined_refined_method_defined.rb (740 Bytes)
0001-vm_method.c-method-defined-should-not-use-refinement.patch (3.95 KB)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 6+ messages in thread
* [ruby-core:67812] [ruby-trunk - Bug #10753] Refined class returns unexpected value when call public_method_defined?, protected_method_defined?, private_method_defined?
[not found] <redmine.issue-10753.20150117184431@ruby-lang.org>
` (2 preceding siblings ...)
2015-01-18 6:57 ` [ruby-core:67672] [ruby-trunk - Bug #10753] [Closed] " nobu
@ 2015-01-26 7:30 ` naruse
2015-02-25 5:42 ` [ruby-core:68300] [Ruby trunk " usa
2015-03-17 15:56 ` [ruby-core:68543] " nagachika00
5 siblings, 0 replies; 6+ messages in thread
From: naruse @ 2015-01-26 7:30 UTC (permalink / raw
To: ruby-core
Issue #10753 has been updated by Yui NARUSE.
Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: REQUIRED to 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: DONE
ruby_2_2 r49409 merged revision(s) 49322.
----------------------------------------
Bug #10753: Refined class returns unexpected value when call public_method_defined?, protected_method_defined?, private_method_defined?
https://bugs.ruby-lang.org/issues/10753#change-51220
* Author: Seiei Higa
* Status: Closed
* Priority: Normal
* Assignee:
* ruby -v: ruby 2.3.0dev (2015-01-18 trunk 49312) [x86_64-darwin14]
* Backport: 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: DONE
----------------------------------------
When I call `public_method_defined?` or `protected_method_defined?` or `private_method_defined?` methods of the class,
the result is not expected if the method is refined.
i confirmed with following example programs in ruby-trunk, 2.0.0-p598, 2.1.5, 2.2.0
examples
=======
bug_refined_method_defined.rb
-----------------------------
``` ruby
c = Class.new do
def refined_public; end
def refined_protected; end
def refined_private; end
public :refined_public
protected :refined_protected
private :refined_private
end
m = Module.new do
refine(c) do
def refined_public; end
def refined_protected; end
def refined_private; end
public :refined_public
protected :refined_protected
private :refined_private
end
end
using m
predicate_methods = %i(
method_defined?
public_method_defined?
protected_method_defined?
private_method_defined?
)
methods = %i(
refined_public
refined_protected
refined_private
)
predicate_methods.each do |predicate_method|
puts predicate_method
puts '-' * 8
methods.each do |method|
puts "#{predicate_method}(#{method}) # => #{c.send(predicate_method, method)}"
end
puts
end
```
expected:
---------
``` console
$ ./ruby --disable-gems bug_refined_method_defined.rb
method_defined?
--------
method_defined?(refined_public) # => true
method_defined?(refined_protected) # => true
method_defined?(refined_private) # => false
public_method_defined?
--------
public_method_defined?(refined_public) # => true
public_method_defined?(refined_protected) # => false
public_method_defined?(refined_private) # => false
protected_method_defined?
--------
protected_method_defined?(refined_public) # => false
protected_method_defined?(refined_protected) # => true
protected_method_defined?(refined_private) # => false
private_method_defined?
--------
private_method_defined?(refined_public) # => false
private_method_defined?(refined_protected) # => false
private_method_defined?(refined_private) # => true
```
actual:
-------
``` console
$ ./ruby --disable-gems bug_refined_method_defined.rb
method_defined?
--------
method_defined?(refined_public) # => true
method_defined?(refined_protected) # => true
method_defined?(refined_private) # => false
public_method_defined?
--------
public_method_defined?(refined_public) # => true
public_method_defined?(refined_protected) # => true
public_method_defined?(refined_private) # => true
protected_method_defined?
--------
protected_method_defined?(refined_public) # => false
protected_method_defined?(refined_protected) # => false
protected_method_defined?(refined_private) # => false
private_method_defined?
--------
private_method_defined?(refined_public) # => false
private_method_defined?(refined_protected) # => false
private_method_defined?(refined_private) # => false
```
bug_undefined_refined_method_defined.rb
=======================================
``` ruby
c = Class.new
m = Module.new do
refine(c) do
def undefined_refined_public; end
def undefined_refined_protected; end
def undefined_refined_private; end
public :undefined_refined_public
protected :undefined_refined_protected
private :undefined_refined_private
end
end
using m
predicate_methods = %i(
method_defined?
public_method_defined?
protected_method_defined?
private_method_defined?
)
methods = %i(
undefined_refined_public
undefined_refined_protected
undefined_refined_private
)
predicate_methods.each do |predicate_method|
puts predicate_method
puts '-' * 8
methods.each do |method|
puts "#{predicate_method}(#{method}) # => #{c.send(predicate_method, method)}"
end
puts
end
```
expected:
---------
``` console
$ ./ruby --disable-gems bug_undefined_refined_method_defined.rb
method_defined?
--------
method_defined?(undefined_refined_public) # => false
method_defined?(undefined_refined_protected) # => false
method_defined?(undefined_refined_private) # => false
public_method_defined?
--------
public_method_defined?(undefined_refined_public) # => false
public_method_defined?(undefined_refined_protected) # => false
public_method_defined?(undefined_refined_private) # => false
protected_method_defined?
--------
protected_method_defined?(undefined_refined_public) # => false
protected_method_defined?(undefined_refined_protected) # => false
protected_method_defined?(undefined_refined_private) # => false
private_method_defined?
--------
private_method_defined?(undefined_refined_public) # => false
private_method_defined?(undefined_refined_protected) # => false
private_method_defined?(undefined_refined_private) # => false
```
actual:
-------
``` console
$ ./ruby --disable-gems bug_undefined_refined_method_defined.rb
method_defined?
--------
method_defined?(undefined_refined_public) # => false
method_defined?(undefined_refined_protected) # => false
method_defined?(undefined_refined_private) # => false
public_method_defined?
--------
public_method_defined?(undefined_refined_public) # => true
public_method_defined?(undefined_refined_protected) # => true
public_method_defined?(undefined_refined_private) # => true
protected_method_defined?
--------
protected_method_defined?(undefined_refined_public) # => false
protected_method_defined?(undefined_refined_protected) # => false
protected_method_defined?(undefined_refined_private) # => false
private_method_defined?
--------
private_method_defined?(undefined_refined_public) # => false
private_method_defined?(undefined_refined_protected) # => false
private_method_defined?(undefined_refined_private) # => false
```
---Files--------------------------------
bug_refined_method_defined.rb (825 Bytes)
bug_undefined_refined_method_defined.rb (740 Bytes)
0001-vm_method.c-method-defined-should-not-use-refinement.patch (3.95 KB)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 6+ messages in thread
* [ruby-core:68300] [Ruby trunk - Bug #10753] Refined class returns unexpected value when call public_method_defined?, protected_method_defined?, private_method_defined?
[not found] <redmine.issue-10753.20150117184431@ruby-lang.org>
` (3 preceding siblings ...)
2015-01-26 7:30 ` [ruby-core:67812] [ruby-trunk - Bug #10753] " naruse
@ 2015-02-25 5:42 ` usa
2015-03-17 15:56 ` [ruby-core:68543] " nagachika00
5 siblings, 0 replies; 6+ messages in thread
From: usa @ 2015-02-25 5:42 UTC (permalink / raw
To: ruby-core
Issue #10753 has been updated by Usaku NAKAMURA.
Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED, 2.2: DONE to 2.0.0: DONE, 2.1: REQUIRED, 2.2: DONE
ruby_2_0_0 r49737 merged revision(s) 49322.
----------------------------------------
Bug #10753: Refined class returns unexpected value when call public_method_defined?, protected_method_defined?, private_method_defined?
https://bugs.ruby-lang.org/issues/10753#change-51653
* Author: Seiei Higa
* Status: Closed
* Priority: Normal
* Assignee:
* ruby -v: ruby 2.3.0dev (2015-01-18 trunk 49312) [x86_64-darwin14]
* Backport: 2.0.0: DONE, 2.1: REQUIRED, 2.2: DONE
----------------------------------------
When I call `public_method_defined?` or `protected_method_defined?` or `private_method_defined?` methods of the class,
the result is not expected if the method is refined.
i confirmed with following example programs in ruby-trunk, 2.0.0-p598, 2.1.5, 2.2.0
examples
=======
bug_refined_method_defined.rb
-----------------------------
``` ruby
c = Class.new do
def refined_public; end
def refined_protected; end
def refined_private; end
public :refined_public
protected :refined_protected
private :refined_private
end
m = Module.new do
refine(c) do
def refined_public; end
def refined_protected; end
def refined_private; end
public :refined_public
protected :refined_protected
private :refined_private
end
end
using m
predicate_methods = %i(
method_defined?
public_method_defined?
protected_method_defined?
private_method_defined?
)
methods = %i(
refined_public
refined_protected
refined_private
)
predicate_methods.each do |predicate_method|
puts predicate_method
puts '-' * 8
methods.each do |method|
puts "#{predicate_method}(#{method}) # => #{c.send(predicate_method, method)}"
end
puts
end
```
expected:
---------
``` console
$ ./ruby --disable-gems bug_refined_method_defined.rb
method_defined?
--------
method_defined?(refined_public) # => true
method_defined?(refined_protected) # => true
method_defined?(refined_private) # => false
public_method_defined?
--------
public_method_defined?(refined_public) # => true
public_method_defined?(refined_protected) # => false
public_method_defined?(refined_private) # => false
protected_method_defined?
--------
protected_method_defined?(refined_public) # => false
protected_method_defined?(refined_protected) # => true
protected_method_defined?(refined_private) # => false
private_method_defined?
--------
private_method_defined?(refined_public) # => false
private_method_defined?(refined_protected) # => false
private_method_defined?(refined_private) # => true
```
actual:
-------
``` console
$ ./ruby --disable-gems bug_refined_method_defined.rb
method_defined?
--------
method_defined?(refined_public) # => true
method_defined?(refined_protected) # => true
method_defined?(refined_private) # => false
public_method_defined?
--------
public_method_defined?(refined_public) # => true
public_method_defined?(refined_protected) # => true
public_method_defined?(refined_private) # => true
protected_method_defined?
--------
protected_method_defined?(refined_public) # => false
protected_method_defined?(refined_protected) # => false
protected_method_defined?(refined_private) # => false
private_method_defined?
--------
private_method_defined?(refined_public) # => false
private_method_defined?(refined_protected) # => false
private_method_defined?(refined_private) # => false
```
bug_undefined_refined_method_defined.rb
=======================================
``` ruby
c = Class.new
m = Module.new do
refine(c) do
def undefined_refined_public; end
def undefined_refined_protected; end
def undefined_refined_private; end
public :undefined_refined_public
protected :undefined_refined_protected
private :undefined_refined_private
end
end
using m
predicate_methods = %i(
method_defined?
public_method_defined?
protected_method_defined?
private_method_defined?
)
methods = %i(
undefined_refined_public
undefined_refined_protected
undefined_refined_private
)
predicate_methods.each do |predicate_method|
puts predicate_method
puts '-' * 8
methods.each do |method|
puts "#{predicate_method}(#{method}) # => #{c.send(predicate_method, method)}"
end
puts
end
```
expected:
---------
``` console
$ ./ruby --disable-gems bug_undefined_refined_method_defined.rb
method_defined?
--------
method_defined?(undefined_refined_public) # => false
method_defined?(undefined_refined_protected) # => false
method_defined?(undefined_refined_private) # => false
public_method_defined?
--------
public_method_defined?(undefined_refined_public) # => false
public_method_defined?(undefined_refined_protected) # => false
public_method_defined?(undefined_refined_private) # => false
protected_method_defined?
--------
protected_method_defined?(undefined_refined_public) # => false
protected_method_defined?(undefined_refined_protected) # => false
protected_method_defined?(undefined_refined_private) # => false
private_method_defined?
--------
private_method_defined?(undefined_refined_public) # => false
private_method_defined?(undefined_refined_protected) # => false
private_method_defined?(undefined_refined_private) # => false
```
actual:
-------
``` console
$ ./ruby --disable-gems bug_undefined_refined_method_defined.rb
method_defined?
--------
method_defined?(undefined_refined_public) # => false
method_defined?(undefined_refined_protected) # => false
method_defined?(undefined_refined_private) # => false
public_method_defined?
--------
public_method_defined?(undefined_refined_public) # => true
public_method_defined?(undefined_refined_protected) # => true
public_method_defined?(undefined_refined_private) # => true
protected_method_defined?
--------
protected_method_defined?(undefined_refined_public) # => false
protected_method_defined?(undefined_refined_protected) # => false
protected_method_defined?(undefined_refined_private) # => false
private_method_defined?
--------
private_method_defined?(undefined_refined_public) # => false
private_method_defined?(undefined_refined_protected) # => false
private_method_defined?(undefined_refined_private) # => false
```
---Files--------------------------------
bug_refined_method_defined.rb (825 Bytes)
bug_undefined_refined_method_defined.rb (740 Bytes)
0001-vm_method.c-method-defined-should-not-use-refinement.patch (3.95 KB)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 6+ messages in thread
* [ruby-core:68543] [Ruby trunk - Bug #10753] Refined class returns unexpected value when call public_method_defined?, protected_method_defined?, private_method_defined?
[not found] <redmine.issue-10753.20150117184431@ruby-lang.org>
` (4 preceding siblings ...)
2015-02-25 5:42 ` [ruby-core:68300] [Ruby trunk " usa
@ 2015-03-17 15:56 ` nagachika00
5 siblings, 0 replies; 6+ messages in thread
From: nagachika00 @ 2015-03-17 15:56 UTC (permalink / raw
To: ruby-core
Issue #10753 has been updated by Tomoyuki Chikanaga.
Backport changed from 2.0.0: DONE, 2.1: REQUIRED, 2.2: DONE to 2.0.0: DONE, 2.1: DONE, 2.2: DONE
Backported into `ruby_2_1` branch at r49991.
----------------------------------------
Bug #10753: Refined class returns unexpected value when call public_method_defined?, protected_method_defined?, private_method_defined?
https://bugs.ruby-lang.org/issues/10753#change-51862
* Author: Seiei Higa
* Status: Closed
* Priority: Normal
* Assignee:
* ruby -v: ruby 2.3.0dev (2015-01-18 trunk 49312) [x86_64-darwin14]
* Backport: 2.0.0: DONE, 2.1: DONE, 2.2: DONE
----------------------------------------
When I call `public_method_defined?` or `protected_method_defined?` or `private_method_defined?` methods of the class,
the result is not expected if the method is refined.
i confirmed with following example programs in ruby-trunk, 2.0.0-p598, 2.1.5, 2.2.0
examples
=======
bug_refined_method_defined.rb
-----------------------------
``` ruby
c = Class.new do
def refined_public; end
def refined_protected; end
def refined_private; end
public :refined_public
protected :refined_protected
private :refined_private
end
m = Module.new do
refine(c) do
def refined_public; end
def refined_protected; end
def refined_private; end
public :refined_public
protected :refined_protected
private :refined_private
end
end
using m
predicate_methods = %i(
method_defined?
public_method_defined?
protected_method_defined?
private_method_defined?
)
methods = %i(
refined_public
refined_protected
refined_private
)
predicate_methods.each do |predicate_method|
puts predicate_method
puts '-' * 8
methods.each do |method|
puts "#{predicate_method}(#{method}) # => #{c.send(predicate_method, method)}"
end
puts
end
```
expected:
---------
``` console
$ ./ruby --disable-gems bug_refined_method_defined.rb
method_defined?
--------
method_defined?(refined_public) # => true
method_defined?(refined_protected) # => true
method_defined?(refined_private) # => false
public_method_defined?
--------
public_method_defined?(refined_public) # => true
public_method_defined?(refined_protected) # => false
public_method_defined?(refined_private) # => false
protected_method_defined?
--------
protected_method_defined?(refined_public) # => false
protected_method_defined?(refined_protected) # => true
protected_method_defined?(refined_private) # => false
private_method_defined?
--------
private_method_defined?(refined_public) # => false
private_method_defined?(refined_protected) # => false
private_method_defined?(refined_private) # => true
```
actual:
-------
``` console
$ ./ruby --disable-gems bug_refined_method_defined.rb
method_defined?
--------
method_defined?(refined_public) # => true
method_defined?(refined_protected) # => true
method_defined?(refined_private) # => false
public_method_defined?
--------
public_method_defined?(refined_public) # => true
public_method_defined?(refined_protected) # => true
public_method_defined?(refined_private) # => true
protected_method_defined?
--------
protected_method_defined?(refined_public) # => false
protected_method_defined?(refined_protected) # => false
protected_method_defined?(refined_private) # => false
private_method_defined?
--------
private_method_defined?(refined_public) # => false
private_method_defined?(refined_protected) # => false
private_method_defined?(refined_private) # => false
```
bug_undefined_refined_method_defined.rb
=======================================
``` ruby
c = Class.new
m = Module.new do
refine(c) do
def undefined_refined_public; end
def undefined_refined_protected; end
def undefined_refined_private; end
public :undefined_refined_public
protected :undefined_refined_protected
private :undefined_refined_private
end
end
using m
predicate_methods = %i(
method_defined?
public_method_defined?
protected_method_defined?
private_method_defined?
)
methods = %i(
undefined_refined_public
undefined_refined_protected
undefined_refined_private
)
predicate_methods.each do |predicate_method|
puts predicate_method
puts '-' * 8
methods.each do |method|
puts "#{predicate_method}(#{method}) # => #{c.send(predicate_method, method)}"
end
puts
end
```
expected:
---------
``` console
$ ./ruby --disable-gems bug_undefined_refined_method_defined.rb
method_defined?
--------
method_defined?(undefined_refined_public) # => false
method_defined?(undefined_refined_protected) # => false
method_defined?(undefined_refined_private) # => false
public_method_defined?
--------
public_method_defined?(undefined_refined_public) # => false
public_method_defined?(undefined_refined_protected) # => false
public_method_defined?(undefined_refined_private) # => false
protected_method_defined?
--------
protected_method_defined?(undefined_refined_public) # => false
protected_method_defined?(undefined_refined_protected) # => false
protected_method_defined?(undefined_refined_private) # => false
private_method_defined?
--------
private_method_defined?(undefined_refined_public) # => false
private_method_defined?(undefined_refined_protected) # => false
private_method_defined?(undefined_refined_private) # => false
```
actual:
-------
``` console
$ ./ruby --disable-gems bug_undefined_refined_method_defined.rb
method_defined?
--------
method_defined?(undefined_refined_public) # => false
method_defined?(undefined_refined_protected) # => false
method_defined?(undefined_refined_private) # => false
public_method_defined?
--------
public_method_defined?(undefined_refined_public) # => true
public_method_defined?(undefined_refined_protected) # => true
public_method_defined?(undefined_refined_private) # => true
protected_method_defined?
--------
protected_method_defined?(undefined_refined_public) # => false
protected_method_defined?(undefined_refined_protected) # => false
protected_method_defined?(undefined_refined_private) # => false
private_method_defined?
--------
private_method_defined?(undefined_refined_public) # => false
private_method_defined?(undefined_refined_protected) # => false
private_method_defined?(undefined_refined_private) # => false
```
---Files--------------------------------
bug_refined_method_defined.rb (825 Bytes)
bug_undefined_refined_method_defined.rb (740 Bytes)
0001-vm_method.c-method-defined-should-not-use-refinement.patch (3.95 KB)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-03-17 15:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <redmine.issue-10753.20150117184431@ruby-lang.org>
2015-01-17 18:44 ` [ruby-core:67656] [ruby-trunk - Bug #10753] [Open] Refined class returns unexpected value when call public_method_defined?, protected_method_defined?, private_method_defined? hanachin
2015-01-17 18:47 ` [ruby-core:67657] [ruby-trunk - Bug #10753] " hanachin
2015-01-18 6:57 ` [ruby-core:67672] [ruby-trunk - Bug #10753] [Closed] " nobu
2015-01-26 7:30 ` [ruby-core:67812] [ruby-trunk - Bug #10753] " naruse
2015-02-25 5:42 ` [ruby-core:68300] [Ruby trunk " usa
2015-03-17 15:56 ` [ruby-core:68543] " nagachika00
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).