ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: mtsmfm@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:80748] [Ruby trunk Bug#13446] refinements with prepend for module has strange behavior
Date: Tue, 18 Apr 2017 01:17:31 +0000	[thread overview]
Message-ID: <redmine.issue-13446.20170418011731.3262a0ec36003c08@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-13446.20170418011731@ruby-lang.org

Issue #13446 has been reported by mtsmfm (Fumiaki Matsushima).

----------------------------------------
Bug #13446: refinements with prepend for module has strange behavior
https://bugs.ruby-lang.org/issues/13446

* Author: mtsmfm (Fumiaki Matsushima)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
~~~
using Module.new {
  refine Enumerable do
    alias :orig_sum :sum
  end
}

module Enumerable
  def sum(*args)
    orig_sum(*args)
  end
end

class GenericEnumerable
  include Enumerable

  def each
  end
end

# GenericEnumerable.new.sum # if we uncomment this line, `GenericEnumerable#sum` will work
Enumerable.prepend(Module.new) # if we comment out this line, `GenericEnumerable#sum` will work

p GenericEnumerable.new.sum # undefined method `orig_sum' for #<GenericEnumerable:0x0000000127c120 @values=[1, 2, 3]> (NoMethodError)
~~~

Is this intentional?



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

       reply	other threads:[~2017-04-18  0:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-13446.20170418011731@ruby-lang.org>
2017-04-18  1:17 ` mtsmfm [this message]
2017-06-16  2:28 ` [ruby-core:81696] [Ruby trunk Bug#13446][Assigned] refinements with prepend for module has strange behavior nobu
2019-10-12 23:51 ` [ruby-core:95310] [Ruby master Bug#13446] " merch-redmine

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.issue-13446.20170418011731.3262a0ec36003c08@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).