Some wierd Module#append_features behavior

B

Brian Mitchell

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

Brian Mitchell

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?

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

Brian.
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: Some wierd Module#append_features behavior"

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

Brian Mitchell

Hi,

In message "Re: Some wierd Module#append_features behavior"

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

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

Yukihiro Matsumoto

Hi,

In message "Re: Some wierd Module#append_features behavior"

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top