Forum: Ruby bug: power! does not work then works in irb

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
solsTiCe d'Hiver (Guest)
on 2006-04-09 17:22
(Received via mailing list)
hi.

here is a session in irb:
irb(main):001:0> 10.power!(200)
NoMethodError: undefined method `power!' for 10:Fixnum
        from (irb):1
irb(main):002:0> help Fixnum
=> nil
irb(main):003:0> 10.power!(200)
=>
100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
irb(main):004:0> quit

so a call to help Fixnum makes the power! method to be available ?

i use slackare 10.2 with a self-made package of ruby 1.8.4 compiled with
CFLAGS="-O2 -march=$arch -mcpu=i686" \
CXXFLAGS="-O2 -march=$arch -mcpu=i686"\
./configure --prefix=/usr --enable-shared
make
make install DESTDIR=$pkg
make install-doc DESTDIR=$pkg

on an Athlon XP 1800+

# note:
not all people on #ruby-lang on irc.freenode.net got that error
Keith L. (Guest)
on 2006-04-09 17:28
(Received via mailing list)
I just tried this on Osx and got the same result!

Keith
Brian M. (Guest)
on 2006-04-09 17:31
(Received via mailing list)
Hi,

You probably saw my reply on IRC but for others...

2006/4/9, solsTiCe d'Hiver <removed_email_address@domain.invalid>:
> hi.
>
> here is a session in irb:
> irb(main):001:0> 10.power!(200)
> NoMethodError: undefined method `power!' for 10:Fixnum
>         from (irb):1
> irb(main):002:0> help Fixnum
> => nil

This is actually a valid call. To see what help is from try:

method :help

You might get something like:

#<Method: Object(IRB::ExtendCommandBundle)#help>

The part in () tells us that it is from IRB... a quick check shows
that a trail is started
that eventually leads to:

require 'mathn'

That file in turn, does something like:

alias power! **

The reason not all people got the error is because some were probably
loading other code at startup or before testing. Rubygems is an
example of this.

Moral of the story is to be away of what your ruby environment
automatically brings in.

Brian.
unknown (Guest)
on 2006-04-09 17:44
(Received via mailing list)
Hi,

At Sun, 9 Apr 2006 22:19:23 +0900,
solsTiCe d'Hiver wrote in [ruby-talk:188278]:
> here is a session in irb:
> irb(main):001:0> 10.power!(200)
> NoMethodError: undefined method `power!' for 10:Fixnum
>         from (irb):1

power! is for internal use only.  Do not use.
Bernard K. (Guest)
on 2006-04-09 20:45
(Received via mailing list)
----- Original Message -----
From: "solsTiCe d'Hiver" <removed_email_address@domain.invalid>
To: "ruby-talk ML" <removed_email_address@domain.invalid>
Sent: Sunday, April 09, 2006 9:19 AM
Subject: [ruby 1.8.4] bug: power! does not work then works in irb


> 
100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
> irb(main):004:0> quit
>
> so a call to help Fixnum makes the power! method to be available ?
>

I get the same behavior  .. using ruby on Windows XP ... the binary
distribution
This topic is locked and can not be replied to.