# Some wierd Module#append\_features behavior

**URL:** <https://www.ruby-forum.com/t/some-wierd-module-append-features-behavior/71199>\
**Category:** Ruby\
**Created:** [October 6, 2006, 1:06am UTC](https://www.ruby-forum.com/t/some-wierd-module-append-features-behavior/71199 "2006-10-06T01:06:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bdmcnitt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a4c791/32.png) [@bdmcnitt](https://www.ruby-forum.com/u/bdmcnitt)\
**Post date:** [October 6, 2006, 1:06am UTC](https://www.ruby-forum.com/t/some-wierd-module-append-features-behavior/71199/1 "2006-10-06T01:06:03Z")

</div>

I couldn’t quite figure this out… I am either missing something (I  
hope) or there is a small bug:

Module === Module #=\> true  
Module === Module.new #=\> true

af = Module.instance\_method(:append\_features)

af.bind(Module.new).call(Module) # ok  
af.bind(Module.new).call(Module.new) # ok  
af.bind(Module).call(Module) # ok  
af.bind(Module).call(Module.new) # error!

TypeError: wrong argument type Class (expected Module)

I am kind of puzzled by this… any ideas?

Brian.

---

<div class="post-metadata">

**Author:** ![bdmcnitt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a4c791/32.png) [@bdmcnitt](https://www.ruby-forum.com/u/bdmcnitt)\
**Post date:** [October 6, 2006, 1:20am UTC](https://www.ruby-forum.com/t/some-wierd-module-append-features-behavior/71199/2 "2006-10-06T01:20:04Z")

</div>

On 10/5/06, Brian M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> af.bind(Module).call(Module) # ok  
> af.bind(Module).call(Module.new) # error!
> 
> TypeError: wrong argument type Class (expected Module)
> 
> I am kind of puzzled by this… any ideas?

To be more specific, the third “ok” is unexpected if the fourth is not  
going to work (which went as I expected).

Brian.

---

<div class="post-metadata">

**Author:** ![bdmcnitt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a4c791/32.png) [@bdmcnitt](https://www.ruby-forum.com/u/bdmcnitt)\
**Post date:** [October 6, 2006, 6:04am UTC](https://www.ruby-forum.com/t/some-wierd-module-append-features-behavior/71199/3 "2006-10-06T06:04:34Z")

</div>

Hi,

In message “Re: Some wierd Module#append\_features behavior”  
on Fri, 6 Oct 2006 08:04:27 +0900, “Brian M.”  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|af.bind(Module).call(Module.new) # error!  
|  
|TypeError: wrong argument type Class (expected Module)  
|  
|I am kind of puzzled by this… any ideas?

append\_feature tried to append features in Module to a module from  
Module.new, but Module itself is a class, not module.

```
						matz.

```

---

<div class="post-metadata">

**Author:** ![bdmcnitt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a4c791/32.png) [@bdmcnitt](https://www.ruby-forum.com/u/bdmcnitt)\
**Post date:** [October 6, 2006, 4:06pm UTC](https://www.ruby-forum.com/t/some-wierd-module-append-features-behavior/71199/4 "2006-10-06T16:06:02Z")

</div>

On 10/6/06, Yukihiro M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> append\_feature tried to append features in Module to a module from  
> Module.new, but Module itself is a class, not module.

Yes. I know that part. The odd thing that I should have been more clear  
on is:

af.bind(Module).call(Module).

Module is a Class is both cases but this one seems to work. I am not  
sure why.

Brian.

---

<div class="post-metadata">

**Author:** ![bdmcnitt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a4c791/32.png) [@bdmcnitt](https://www.ruby-forum.com/u/bdmcnitt)\
**Post date:** [October 6, 2006, 5:34pm UTC](https://www.ruby-forum.com/t/some-wierd-module-append-features-behavior/71199/5 "2006-10-06T17:34:27Z")

</div>

Hi,

In message “Re: Some wierd Module#append\_features behavior”  
on Fri, 6 Oct 2006 23:05:41 +0900, “Brian M.”  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|Yes. I know that part. The odd thing that I should have been more clear on is:  
|  
|af.bind(Module).call(Module).  
|  
|Module is a Class is both cases but this one seems to work. I am not sure why.

It is a bug. Thank you for finding it.

```
						matz.

```
