ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:94382] [Ruby master Bug#16107] Module#refine and Module#using behaved unexpectedly
       [not found] <redmine.issue-16107.20190816083455@ruby-lang.org>
@ 2019-08-16  8:34 ` UlyssesZhan
  2019-08-16 10:52 ` [ruby-core:94383] " johnwheeler304
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: UlyssesZhan @ 2019-08-16  8:34 UTC (permalink / raw)
  To: ruby-core

Issue #16107 has been reported by UlyssesZhan (有丘 詹).

----------------------------------------
Bug #16107: Module#refine and Module#using behaved unexpectedly
https://bugs.ruby-lang.org/issues/16107

* Author: UlyssesZhan (有丘 詹)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.6.0p0 (2018-12-25 revision 66547) [x64-mingw32]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
The issue happened when I tried to run the code below:
``` ruby
# Main.rb
class A
end
class B
end

module M1
	refine A do
	  def foo *args
		  puts "foo"
	  end
	end
end

using M1
module M2
	def self.enable_foo
		refine B do
			def call_foo *args
				A.new.foo *args
			end
		end
	end
end

M2.enable_foo
using M2
B.new.call_foo
```
I expected it to output `foo`, but I got this:
```
Traceback (most recent call last):
        1: from Main.rb:28:in `<main>'
Main.rb:20:in `call_foo': undefined method `foo' for #<A:0x000000000719f3a0> (NoMethodError)
Did you mean?  for
```
I tried to put `using M1` in M2 and its singleton class, but the same error was raised.
Maybe it is a Ruby bug. If it is not, I hope to get a workaround when I encounter similiar situations.
`RUBY_VERSION` is `"2.6.0"`, and `RUBY_PLATFORM` is `"x64-mingw32"`.



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

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

* [ruby-core:94383] [Ruby master Bug#16107] Module#refine and Module#using behaved unexpectedly
       [not found] <redmine.issue-16107.20190816083455@ruby-lang.org>
  2019-08-16  8:34 ` [ruby-core:94382] [Ruby master Bug#16107] Module#refine and Module#using behaved unexpectedly UlyssesZhan
@ 2019-08-16 10:52 ` johnwheeler304
  2019-08-16 13:19 ` [ruby-core:94386] " nobu
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: johnwheeler304 @ 2019-08-16 10:52 UTC (permalink / raw)
  To: ruby-core

Issue #16107 has been updated by webhostingscoupon (john wheeler).


It was very much created and straightforward. Not at all like extra web journals I have perused which are truly not unreasonably great. I likewise discovered your "Hostgator Coupons 2019":https://www.webhostingscoupon.com/hostgator-coupon-code.html posts exceptionally intriguing certainty subsequent to perusing. I needed to go show it to my companion and he delighted in it too!

----------------------------------------
Bug #16107: Module#refine and Module#using behaved unexpectedly
https://bugs.ruby-lang.org/issues/16107#change-80798

* Author: UlyssesZhan (有丘 詹)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.6.0p0 (2018-12-25 revision 66547) [x64-mingw32]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
The issue happened when I tried to run the code below:
``` ruby
# Main.rb
class A
end
class B
end

module M1
	refine A do
	  def foo *args
		  puts "foo"
	  end
	end
end

using M1
module M2
	def self.enable_foo
		refine B do
			def call_foo *args
				A.new.foo *args
			end
		end
	end
end

M2.enable_foo
using M2
B.new.call_foo
```
I expected it to output `foo`, but I got this:
```
Traceback (most recent call last):
        1: from Main.rb:28:in `<main>'
Main.rb:20:in `call_foo': undefined method `foo' for #<A:0x000000000719f3a0> (NoMethodError)
Did you mean?  for
```
I tried to put `using M1` in M2 and its singleton class, but the same error was raised.
Maybe it is a Ruby bug. If it is not, I hope to get a workaround when I encounter similiar situations.
`RUBY_VERSION` is `"2.6.0"`, and `RUBY_PLATFORM` is `"x64-mingw32"`.



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

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

* [ruby-core:94386] [Ruby master Bug#16107] Module#refine and Module#using behaved unexpectedly
       [not found] <redmine.issue-16107.20190816083455@ruby-lang.org>
  2019-08-16  8:34 ` [ruby-core:94382] [Ruby master Bug#16107] Module#refine and Module#using behaved unexpectedly UlyssesZhan
  2019-08-16 10:52 ` [ruby-core:94383] " johnwheeler304
@ 2019-08-16 13:19 ` nobu
  2019-08-16 13:25 ` [ruby-core:94387] " manga.osyo
  2019-08-16 15:19 ` [ruby-core:94390] " nobu
  4 siblings, 0 replies; 5+ messages in thread
From: nobu @ 2019-08-16 13:19 UTC (permalink / raw)
  To: ruby-core

Issue #16107 has been updated by nobu (Nobuyoshi Nakada).


I shortened the example a little.

```ruby
class A
end

module M1
  refine A do
    def foo
      puts "foo"
    end
  end
end

module M2
  using M1
  refine A do
    A.new.foo
  end
end
```

It seems that a `refine` block does not inherit outer `using`s.


----------------------------------------
Bug #16107: Module#refine and Module#using behaved unexpectedly
https://bugs.ruby-lang.org/issues/16107#change-80801

* Author: UlyssesZhan (有丘 詹)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.6.0p0 (2018-12-25 revision 66547) [x64-mingw32]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
The issue happened when I tried to run the code below:
``` ruby
# Main.rb
class A
end
class B
end

module M1
	refine A do
	  def foo *args
		  puts "foo"
	  end
	end
end

using M1
module M2
	def self.enable_foo
		refine B do
			def call_foo *args
				A.new.foo *args
			end
		end
	end
end

M2.enable_foo
using M2
B.new.call_foo
```
I expected it to output `foo`, but I got this:
```
Traceback (most recent call last):
        1: from Main.rb:28:in `<main>'
Main.rb:20:in `call_foo': undefined method `foo' for #<A:0x000000000719f3a0> (NoMethodError)
Did you mean?  for
```
I tried to put `using M1` in M2 and its singleton class, but the same error was raised.
Maybe it is a Ruby bug. If it is not, I hope to get a workaround when I encounter similiar situations.
`RUBY_VERSION` is `"2.6.0"`, and `RUBY_PLATFORM` is `"x64-mingw32"`.



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

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

* [ruby-core:94387] [Ruby master Bug#16107] Module#refine and Module#using behaved unexpectedly
       [not found] <redmine.issue-16107.20190816083455@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2019-08-16 13:19 ` [ruby-core:94386] " nobu
@ 2019-08-16 13:25 ` manga.osyo
  2019-08-16 15:19 ` [ruby-core:94390] " nobu
  4 siblings, 0 replies; 5+ messages in thread
From: manga.osyo @ 2019-08-16 13:25 UTC (permalink / raw)
  To: ruby-core

Issue #16107 has been updated by osyo (manga osyo).


(FYI) It works if you `using M1` it in `refine` .

```ruby
class A
end

module M1
  refine A do
    def foo
      puts "foo"
    end
  end
end

module M2
  refine A do
    using M1

    # OK
    A.new.foo
  end
end
```

https://wandbox.org/permlink/P1vRSmsHAex7MpSL

----------------------------------------
Bug #16107: Module#refine and Module#using behaved unexpectedly
https://bugs.ruby-lang.org/issues/16107#change-80802

* Author: UlyssesZhan (有丘 詹)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.6.0p0 (2018-12-25 revision 66547) [x64-mingw32]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
The issue happened when I tried to run the code below:
``` ruby
# Main.rb
class A
end
class B
end

module M1
	refine A do
	  def foo *args
		  puts "foo"
	  end
	end
end

using M1
module M2
	def self.enable_foo
		refine B do
			def call_foo *args
				A.new.foo *args
			end
		end
	end
end

M2.enable_foo
using M2
B.new.call_foo
```
I expected it to output `foo`, but I got this:
```
Traceback (most recent call last):
        1: from Main.rb:28:in `<main>'
Main.rb:20:in `call_foo': undefined method `foo' for #<A:0x000000000719f3a0> (NoMethodError)
Did you mean?  for
```
I tried to put `using M1` in M2 and its singleton class, but the same error was raised.
Maybe it is a Ruby bug. If it is not, I hope to get a workaround when I encounter similiar situations.
`RUBY_VERSION` is `"2.6.0"`, and `RUBY_PLATFORM` is `"x64-mingw32"`.



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

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

* [ruby-core:94390] [Ruby master Bug#16107] Module#refine and Module#using behaved unexpectedly
       [not found] <redmine.issue-16107.20190816083455@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2019-08-16 13:25 ` [ruby-core:94387] " manga.osyo
@ 2019-08-16 15:19 ` nobu
  4 siblings, 0 replies; 5+ messages in thread
From: nobu @ 2019-08-16 15:19 UTC (permalink / raw)
  To: ruby-core

Issue #16107 has been updated by nobu (Nobuyoshi Nakada).


https://github.com/ruby/ruby/pull/2373

----------------------------------------
Bug #16107: Module#refine and Module#using behaved unexpectedly
https://bugs.ruby-lang.org/issues/16107#change-80805

* Author: UlyssesZhan (有丘 詹)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.6.0p0 (2018-12-25 revision 66547) [x64-mingw32]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
The issue happened when I tried to run the code below:
``` ruby
# Main.rb
class A
end
class B
end

module M1
	refine A do
	  def foo *args
		  puts "foo"
	  end
	end
end

using M1
module M2
	def self.enable_foo
		refine B do
			def call_foo *args
				A.new.foo *args
			end
		end
	end
end

M2.enable_foo
using M2
B.new.call_foo
```
I expected it to output `foo`, but I got this:
```
Traceback (most recent call last):
        1: from Main.rb:28:in `<main>'
Main.rb:20:in `call_foo': undefined method `foo' for #<A:0x000000000719f3a0> (NoMethodError)
Did you mean?  for
```
I tried to put `using M1` in M2 and its singleton class, but the same error was raised.
Maybe it is a Ruby bug. If it is not, I hope to get a workaround when I encounter similiar situations.
`RUBY_VERSION` is `"2.6.0"`, and `RUBY_PLATFORM` is `"x64-mingw32"`.



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

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

end of thread, other threads:[~2019-08-16 15:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-16107.20190816083455@ruby-lang.org>
2019-08-16  8:34 ` [ruby-core:94382] [Ruby master Bug#16107] Module#refine and Module#using behaved unexpectedly UlyssesZhan
2019-08-16 10:52 ` [ruby-core:94383] " johnwheeler304
2019-08-16 13:19 ` [ruby-core:94386] " nobu
2019-08-16 13:25 ` [ruby-core:94387] " manga.osyo
2019-08-16 15:19 ` [ruby-core:94390] " nobu

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).