Project

General

Profile

Backport #8025

Module#included_modules includes classes

Added by marcandre (Marc-Andre Lafortune) over 6 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Normal
[ruby-core:53158]

Description

I see two problems in the following code:

module Mixin
end

class C
  prepend Mixin
end

C.included_modules # => [Mixin, C, Kernel]

1) C should definitely not be there, since no class should ever appear in that list.

2) I wonder if Mixin should be there, since it was prepended to C, not included.


Related issues

Related to Ruby trunk - Bug #8841: Module#included_modules and prepended modulesOpenActions

Associated revisions

Revision 3fd0000c
Added by nobu (Nobuyoshi Nakada) about 6 years ago

class.c: exclude original module

  • class.c (rb_mod_included_modules): should not include the original module itself. [ruby-core:53158] [Bug #8025]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 40612
Added by nobu (Nobuyoshi Nakada) about 6 years ago

class.c: exclude original module

  • class.c (rb_mod_included_modules): should not include the original module itself. [ruby-core:53158] [Bug #8025]

Revision 40612
Added by nobu (Nobuyoshi Nakada) about 6 years ago

class.c: exclude original module

  • class.c (rb_mod_included_modules): should not include the original module itself. [ruby-core:53158] [Bug #8025]

Revision 40612
Added by nobu (Nobuyoshi Nakada) about 6 years ago

class.c: exclude original module

  • class.c (rb_mod_included_modules): should not include the original module itself. [ruby-core:53158] [Bug #8025]

Revision 40612
Added by nobu (Nobuyoshi Nakada) about 6 years ago

class.c: exclude original module

  • class.c (rb_mod_included_modules): should not include the original module itself. [ruby-core:53158] [Bug #8025]

Revision 40612
Added by nobu (Nobuyoshi Nakada) about 6 years ago

class.c: exclude original module

  • class.c (rb_mod_included_modules): should not include the original module itself. [ruby-core:53158] [Bug #8025]

Revision 40612
Added by nobu (Nobuyoshi Nakada) about 6 years ago

class.c: exclude original module

  • class.c (rb_mod_included_modules): should not include the original module itself. [ruby-core:53158] [Bug #8025]

Revision e8bdef65
Added by nobu (Nobuyoshi Nakada) about 6 years ago

class.c: include modules only

  • class.c (rb_mod_included_modules): should not include non-modules. [ruby-core:53158] [Bug #8025]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 40614
Added by nobu (Nobuyoshi Nakada) about 6 years ago

class.c: include modules only

  • class.c (rb_mod_included_modules): should not include non-modules. [ruby-core:53158] [Bug #8025]

Revision 40614
Added by nobu (Nobuyoshi Nakada) about 6 years ago

class.c: include modules only

  • class.c (rb_mod_included_modules): should not include non-modules. [ruby-core:53158] [Bug #8025]

Revision 40614
Added by nobu (Nobuyoshi Nakada) about 6 years ago

class.c: include modules only

  • class.c (rb_mod_included_modules): should not include non-modules. [ruby-core:53158] [Bug #8025]

Revision 40614
Added by nobu (Nobuyoshi Nakada) about 6 years ago

class.c: include modules only

  • class.c (rb_mod_included_modules): should not include non-modules. [ruby-core:53158] [Bug #8025]

Revision 40614
Added by nobu (Nobuyoshi Nakada) about 6 years ago

class.c: include modules only

  • class.c (rb_mod_included_modules): should not include non-modules. [ruby-core:53158] [Bug #8025]

Revision 40614
Added by nobu (Nobuyoshi Nakada) about 6 years ago

class.c: include modules only

  • class.c (rb_mod_included_modules): should not include non-modules. [ruby-core:53158] [Bug #8025]

Revision 2c240c5e
Added by nagachika (Tomoyuki Chikanaga) about 6 years ago

merge revision(s) 40612,40614: [Backport #8025]

    * class.c (rb_mod_included_modules): should not include the original
      module itself.  [ruby-core:53158] [Bug #8025]

    * class.c (rb_mod_included_modules): should not include non-modules.
      [ruby-core:53158] [Bug #8025]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@40627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 40627
Added by nagachika (Tomoyuki Chikanaga) about 6 years ago

merge revision(s) 40612,40614: [Backport #8025]

* class.c (rb_mod_included_modules): should not include the original
  module itself.  [ruby-core:53158] [Bug #8025]

* class.c (rb_mod_included_modules): should not include non-modules.
  [ruby-core:53158] [Bug #8025]

History

#1

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r40612.
Marc-Andre, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


class.c: exclude original module

  • class.c (rb_mod_included_modules): should not include the original module itself. [ruby-core:53158] [Bug #8025]
#2

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby trunk to Backport200
  • Category deleted (core)
  • Status changed from Closed to Assigned
  • Assignee changed from matz (Yukihiro Matsumoto) to nagachika (Tomoyuki Chikanaga)
  • Target version deleted (2.1.0)

Updated by nagachika (Tomoyuki Chikanaga) about 6 years ago

  • Assignee changed from nagachika (Tomoyuki Chikanaga) to nobu (Nobuyoshi Nakada)

Hello,

A problem seems to remain in case of inherited Class was prepended by a Module.
See the following sample.

module M1; end

class C1
prepend M1
end

class C2 < C1
end

p C1.included_modules # => [M1, Kernel]
p C2.included_modules # => [M1, C1, Kernel]

Thanks,

Updated by nagachika (Tomoyuki Chikanaga) about 6 years ago

  • Assignee changed from nobu (Nobuyoshi Nakada) to nagachika (Tomoyuki Chikanaga)

r40614 is an additional commit. Thank you nobu.

#5

Updated by nagachika (Tomoyuki Chikanaga) about 6 years ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r40627.
Marc-Andre, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 40612,40614: [Backport #8025]

* class.c (rb_mod_included_modules): should not include the original
  module itself.  [ruby-core:53158] [Bug #8025]

* class.c (rb_mod_included_modules): should not include non-modules.
  [ruby-core:53158] [Bug #8025]

Also available in: Atom PDF