[ruby-core:78151] [Ruby trunk Bug#12920] Strange NoMethodError in Time.now
From:
yanagi@...
Date:
2016-11-15 13:41:53 UTC
List:
ruby-core #78151
Issue #12920 has been updated by Kouhei Yanagita.
This problem happens with Ruby 2.3.2.
~~~
% cat a.rb
Fixnum.prepend(Module.new)
Module.new do
refine Fixnum do
define_method(:+) {}
end
end
Time.now
~~~
~~~
% ruby -v a.rb
ruby 2.3.2p217 (2016-11-15 revision 56796) [x86_64-darwin16]
a.rb:8:in `initialize': undefined method `+' for 1479217045000000000:Fixnum (NoMethodError)
Did you mean? +@
from a.rb:8:in `now'
from a.rb:8:in `<main>'
~~~
----------------------------------------
Bug #12920: Strange NoMethodError in Time.now
https://bugs.ruby-lang.org/issues/12920#change-61511
* Author: Kouhei Yanagita
* Status: Closed
* Priority: Normal
* Assignee:
* ruby -v: ruby 2.4.0dev (2016-11-10 trunk 56692) [x86_64-darwin15]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
I got a strange NoMethodError in Time.now.
~~~
Integer.prepend(Module.new)
module Foo
refine Integer do
define_method(:+) { }
end
end
Time.now
~~~
~~~
% ~/tmp/ruby-trunk/bin/ruby -v a.rb
ruby 2.4.0dev (2016-11-10 trunk 56692) [x86_64-darwin15]
a.rb:7:in `initialize': undefined method `+' for 1478773005000000000:Integer (NoMethodError)
from a.rb:7:in `now'
from a.rb:7:in `<main>'
~~~
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>