ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:59730] [ruby-trunk - Bug #9311] module_function breaks on `singleton_class?`
       [not found] <redmine.issue-9311.20131228033823@ruby-lang.org>
@ 2014-01-13  2:44 ` Hiroshi, SHIBATA
  2014-01-15 23:50 ` [ruby-core:59795] " ruby
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: Hiroshi, SHIBATA @ 2014-01-13  2:44 UTC (permalink / raw
  To: ruby-core

チケット #9311 が Hiroshi SHIBATA によって更新されました。

トラッカー を Backport から Bug に変更
プロジェクト を Backport21 から ruby-trunk に変更
ruby -v を ruby 2.1.0 にセット

----------------------------------------
Bug #9311: module_function breaks on `singleton_class?`
https://bugs.ruby-lang.org/issues/9311#change-44241

* 作成者: Chris Heald
* ステータス: Open
* 優先度: Normal
* 担当者: 
* カテゴリ: 
* 対象バージョン: 
* ruby -v: ruby 2.1.0
* Backport: 
----------------------------------------
=begin
When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:

    [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
    => [:singleton_class?, :singleton_class]
    [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
    NoMethodError: undefined method `method_function' for Sass::Util:Module
    from (pry):6:in `<module:Util>'

This is actually pretty trivially reproduced via:

    2.1.0 :001 > module Foo
    2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
    2.1.0 :003?>   end
    NameError: undefined method `singleton_class?' for module `Foo'
            from (irb):2:in `module_function'
            from (irb):2:in `block in <module:Foo>'
            from (irb):2:in `each'
            from (irb):2:in `<module:Foo>'
            from (irb):1
            from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'

Now, Sass performs the following:

    (Sass::Util.methods - Module.methods).each {|method| module_function method }

This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:

    class Class
      private
      def singleton_class?
        ancestors.first != self
      end
    end

This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):

    2.1.0 :001 > Module.methods.sort
     => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
    2.1.0 :002 > class Class
    2.1.0 :003?>         private
    2.1.0 :004?>         def singleton_class?
    2.1.0 :005?>             ancestors.first != self
    2.1.0 :006?>           end
    2.1.0 :007?>       end
     => :singleton_class?
    2.1.0 :008 > Module.methods.sort
     => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
     
Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.

This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:

    2.0.0p247 :001 > class Class
    2.0.0p247 :002?>   private
    2.0.0p247 :003?>   def singleton_class
    2.0.0p247 :004?>     false
    2.0.0p247 :005?>     end
    2.0.0p247 :006?>   end
     => nil
    2.0.0p247 :007 > module Foo
    2.0.0p247 :008?>   module_function :singleton_class
    2.0.0p247 :009?>   end
     => Foo
    2.0.0p247 :010 > Foo.singleton_class
     => #<Class:Foo>

Which seems to work just fine.
=end




-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:59795] [ruby-trunk - Bug #9311] module_function breaks on `singleton_class?`
       [not found] <redmine.issue-9311.20131228033823@ruby-lang.org>
  2014-01-13  2:44 ` [ruby-core:59730] [ruby-trunk - Bug #9311] module_function breaks on `singleton_class?` Hiroshi, SHIBATA
@ 2014-01-15 23:50 ` ruby
  2014-01-15 23:56 ` [ruby-core:59796] " ruby
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: ruby @ 2014-01-15 23:50 UTC (permalink / raw
  To: ruby-core

Issue #9311 has been updated by Aman Gupta.

File bug9311-test.diff added

Attached regression test for trunk.

----------------------------------------
Bug #9311: module_function breaks on `singleton_class?`
https://bugs.ruby-lang.org/issues/9311#change-44368

* Author: Chris Heald
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.1.0
* Backport: 
----------------------------------------
=begin
When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:

    [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
    => [:singleton_class?, :singleton_class]
    [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
    NoMethodError: undefined method `method_function' for Sass::Util:Module
    from (pry):6:in `<module:Util>'

This is actually pretty trivially reproduced via:

    2.1.0 :001 > module Foo
    2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
    2.1.0 :003?>   end
    NameError: undefined method `singleton_class?' for module `Foo'
            from (irb):2:in `module_function'
            from (irb):2:in `block in <module:Foo>'
            from (irb):2:in `each'
            from (irb):2:in `<module:Foo>'
            from (irb):1
            from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'

Now, Sass performs the following:

    (Sass::Util.methods - Module.methods).each {|method| module_function method }

This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:

    class Class
      private
      def singleton_class?
        ancestors.first != self
      end
    end

This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):

    2.1.0 :001 > Module.methods.sort
     => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
    2.1.0 :002 > class Class
    2.1.0 :003?>         private
    2.1.0 :004?>         def singleton_class?
    2.1.0 :005?>             ancestors.first != self
    2.1.0 :006?>           end
    2.1.0 :007?>       end
     => :singleton_class?
    2.1.0 :008 > Module.methods.sort
     => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
     
Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.

This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:

    2.0.0p247 :001 > class Class
    2.0.0p247 :002?>   private
    2.0.0p247 :003?>   def singleton_class
    2.0.0p247 :004?>     false
    2.0.0p247 :005?>     end
    2.0.0p247 :006?>   end
     => nil
    2.0.0p247 :007 > module Foo
    2.0.0p247 :008?>   module_function :singleton_class
    2.0.0p247 :009?>   end
     => Foo
    2.0.0p247 :010 > Foo.singleton_class
     => #<Class:Foo>

Which seems to work just fine.
=end


---Files--------------------------------
bug9311-test.diff (568 Bytes)


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:59796] [ruby-trunk - Bug #9311] module_function breaks on `singleton_class?`
       [not found] <redmine.issue-9311.20131228033823@ruby-lang.org>
  2014-01-13  2:44 ` [ruby-core:59730] [ruby-trunk - Bug #9311] module_function breaks on `singleton_class?` Hiroshi, SHIBATA
  2014-01-15 23:50 ` [ruby-core:59795] " ruby
@ 2014-01-15 23:56 ` ruby
  2014-01-16  0:06 ` [ruby-core:59797] [ruby-trunk - Bug #9311] [Rejected] " nobu
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: ruby @ 2014-01-15 23:56 UTC (permalink / raw
  To: ruby-core

Issue #9311 has been updated by Aman Gupta.

ruby -v changed from ruby 2.1.0 to -

 Issue #9311 has been updated by Aman Gupta.
 
 File bug9311-test.diff added
 
 Attached regression test for trunk.
 
 ----------------------------------------
 Bug #9311: module_function breaks on `singleton_class?`
 https://bugs.ruby-lang.org/issues/9311#change-44368
 
 * Author: Chris Heald
 * Status: Open
 * Priority: Normal
 * Assignee: 
 * Category: 
 * Target version: 
 * ruby -v: ruby 2.1.0
 * Backport: 
 ----------------------------------------
 =begin
 When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:
 
     [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
     => [:singleton_class?, :singleton_class]
     [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
     NoMethodError: undefined method `method_function' for Sass::Util:Module
     from (pry):6:in `<module:Util>'
 
 This is actually pretty trivially reproduced via:
 
     2.1.0 :001 > module Foo
     2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
     2.1.0 :003?>   end
     NameError: undefined method `singleton_class?' for module `Foo'
             from (irb):2:in `module_function'
             from (irb):2:in `block in <module:Foo>'
             from (irb):2:in `each'
             from (irb):2:in `<module:Foo>'
             from (irb):1
             from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'
 
 Now, Sass performs the following:
 
     (Sass::Util.methods - Module.methods).each {|method| module_function method }
 
 This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:
 
     class Class
       private
       def singleton_class?
         ancestors.first != self
       end
     end
 
 This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):
 
     2.1.0 :001 > Module.methods.sort
      => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
     2.1.0 :002 > class Class
     2.1.0 :003?>         private
     2.1.0 :004?>         def singleton_class?
     2.1.0 :005?>             ancestors.first != self
     2.1.0 :006?>           end
     2.1.0 :007?>       end
      => :singleton_class?
     2.1.0 :008 > Module.methods.sort
      => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
      
 Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.
 
 This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:
 
     2.0.0p247 :001 > class Class
     2.0.0p247 :002?>   private
     2.0.0p247 :003?>   def singleton_class
     2.0.0p247 :004?>     false
     2.0.0p247 :005?>     end
     2.0.0p247 :006?>   end
      => nil
     2.0.0p247 :007 > module Foo
     2.0.0p247 :008?>   module_function :singleton_class
     2.0.0p247 :009?>   end
      => Foo
     2.0.0p247 :010 > Foo.singleton_class
      => #<Class:Foo>
 
 Which seems to work just fine.
 =end
 
 
 ---Files--------------------------------
 bug9311-test.diff (568 Bytes)
 
 
 -- 
 http://bugs.ruby-lang.org/

----------------------------------------
Bug #9311: module_function breaks on `singleton_class?`
https://bugs.ruby-lang.org/issues/9311#change-44369

* Author: Chris Heald
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: -
* Backport: 
----------------------------------------
=begin
When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:

    [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
    => [:singleton_class?, :singleton_class]
    [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
    NoMethodError: undefined method `method_function' for Sass::Util:Module
    from (pry):6:in `<module:Util>'

This is actually pretty trivially reproduced via:

    2.1.0 :001 > module Foo
    2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
    2.1.0 :003?>   end
    NameError: undefined method `singleton_class?' for module `Foo'
            from (irb):2:in `module_function'
            from (irb):2:in `block in <module:Foo>'
            from (irb):2:in `each'
            from (irb):2:in `<module:Foo>'
            from (irb):1
            from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'

Now, Sass performs the following:

    (Sass::Util.methods - Module.methods).each {|method| module_function method }

This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:

    class Class
      private
      def singleton_class?
        ancestors.first != self
      end
    end

This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):

    2.1.0 :001 > Module.methods.sort
     => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
    2.1.0 :002 > class Class
    2.1.0 :003?>         private
    2.1.0 :004?>         def singleton_class?
    2.1.0 :005?>             ancestors.first != self
    2.1.0 :006?>           end
    2.1.0 :007?>       end
     => :singleton_class?
    2.1.0 :008 > Module.methods.sort
     => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
     
Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.

This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:

    2.0.0p247 :001 > class Class
    2.0.0p247 :002?>   private
    2.0.0p247 :003?>   def singleton_class
    2.0.0p247 :004?>     false
    2.0.0p247 :005?>     end
    2.0.0p247 :006?>   end
     => nil
    2.0.0p247 :007 > module Foo
    2.0.0p247 :008?>   module_function :singleton_class
    2.0.0p247 :009?>   end
     => Foo
    2.0.0p247 :010 > Foo.singleton_class
     => #<Class:Foo>

Which seems to work just fine.
=end


---Files--------------------------------
bug9311-test.diff (568 Bytes)


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:59797] [ruby-trunk - Bug #9311] [Rejected] module_function breaks on `singleton_class?`
       [not found] <redmine.issue-9311.20131228033823@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2014-01-15 23:56 ` [ruby-core:59796] " ruby
@ 2014-01-16  0:06 ` nobu
  2014-01-16  0:08 ` [ruby-core:59798] [ruby-trunk - Bug #9311] " ruby
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: nobu @ 2014-01-16  0:06 UTC (permalink / raw
  To: ruby-core

Issue #9311 has been updated by Nobuyoshi Nakada.

Status changed from Open to Rejected

`Module.singleton_class?` is a method of `Module`, not defined in `Module` instances.
Other `singleton_`* methods are defined in `Kernel` as instance methods.

----------------------------------------
Bug #9311: module_function breaks on `singleton_class?`
https://bugs.ruby-lang.org/issues/9311#change-44370

* Author: Chris Heald
* Status: Rejected
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: -
* Backport: 
----------------------------------------
=begin
When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:

    [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
    => [:singleton_class?, :singleton_class]
    [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
    NoMethodError: undefined method `method_function' for Sass::Util:Module
    from (pry):6:in `<module:Util>'

This is actually pretty trivially reproduced via:

    2.1.0 :001 > module Foo
    2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
    2.1.0 :003?>   end
    NameError: undefined method `singleton_class?' for module `Foo'
            from (irb):2:in `module_function'
            from (irb):2:in `block in <module:Foo>'
            from (irb):2:in `each'
            from (irb):2:in `<module:Foo>'
            from (irb):1
            from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'

Now, Sass performs the following:

    (Sass::Util.methods - Module.methods).each {|method| module_function method }

This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:

    class Class
      private
      def singleton_class?
        ancestors.first != self
      end
    end

This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):

    2.1.0 :001 > Module.methods.sort
     => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
    2.1.0 :002 > class Class
    2.1.0 :003?>         private
    2.1.0 :004?>         def singleton_class?
    2.1.0 :005?>             ancestors.first != self
    2.1.0 :006?>           end
    2.1.0 :007?>       end
     => :singleton_class?
    2.1.0 :008 > Module.methods.sort
     => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
     
Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.

This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:

    2.0.0p247 :001 > class Class
    2.0.0p247 :002?>   private
    2.0.0p247 :003?>   def singleton_class
    2.0.0p247 :004?>     false
    2.0.0p247 :005?>     end
    2.0.0p247 :006?>   end
     => nil
    2.0.0p247 :007 > module Foo
    2.0.0p247 :008?>   module_function :singleton_class
    2.0.0p247 :009?>   end
     => Foo
    2.0.0p247 :010 > Foo.singleton_class
     => #<Class:Foo>

Which seems to work just fine.
=end


---Files--------------------------------
bug9311-test.diff (568 Bytes)


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:59798] [ruby-trunk - Bug #9311] module_function breaks on `singleton_class?`
       [not found] <redmine.issue-9311.20131228033823@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2014-01-16  0:06 ` [ruby-core:59797] [ruby-trunk - Bug #9311] [Rejected] " nobu
@ 2014-01-16  0:08 ` ruby
  2014-01-16  0:08 ` [ruby-core:59799] " nobu
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: ruby @ 2014-01-16  0:08 UTC (permalink / raw
  To: ruby-core

Issue #9311 has been updated by Aman Gupta.


 Issue #9311 has been updated by Aman Gupta.
 
 ruby -v changed from ruby 2.1.0 to -
 
  Issue #9311 has been updated by Aman Gupta.
  
  File bug9311-test.diff added
  
  Attached regression test for trunk.
  
  ----------------------------------------
  Bug #9311: module_function breaks on `singleton_class?`
  https://bugs.ruby-lang.org/issues/9311#change-44368
  
  * Author: Chris Heald
  * Status: Open
  * Priority: Normal
  * Assignee: 
  * Category: 
  * Target version: 
  * ruby -v: ruby 2.1.0
  * Backport: 
  ----------------------------------------
  =begin
  When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:
  
      [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
      => [:singleton_class?, :singleton_class]
      [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
      NoMethodError: undefined method `method_function' for Sass::Util:Module
      from (pry):6:in `<module:Util>'
  
  This is actually pretty trivially reproduced via:
  
      2.1.0 :001 > module Foo
      2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
      2.1.0 :003?>   end
      NameError: undefined method `singleton_class?' for module `Foo'
              from (irb):2:in `module_function'
              from (irb):2:in `block in <module:Foo>'
              from (irb):2:in `each'
              from (irb):2:in `<module:Foo>'
              from (irb):1
              from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'
  
  Now, Sass performs the following:
  
      (Sass::Util.methods - Module.methods).each {|method| module_function method }
  
  This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:
  
      class Class
        private
        def singleton_class?
          ancestors.first != self
        end
      end
  
  This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):
  
      2.1.0 :001 > Module.methods.sort
       => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
      2.1.0 :002 > class Class
      2.1.0 :003?>         private
      2.1.0 :004?>         def singleton_class?
      2.1.0 :005?>             ancestors.first != self
      2.1.0 :006?>           end
      2.1.0 :007?>       end
       => :singleton_class?
      2.1.0 :008 > Module.methods.sort
       => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
       
  Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.
  
  This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:
  
      2.0.0p247 :001 > class Class
      2.0.0p247 :002?>   private
      2.0.0p247 :003?>   def singleton_class
      2.0.0p247 :004?>     false
      2.0.0p247 :005?>     end
      2.0.0p247 :006?>   end
       => nil
      2.0.0p247 :007 > module Foo
      2.0.0p247 :008?>   module_function :singleton_class
      2.0.0p247 :009?>   end
       => Foo
      2.0.0p247 :010 > Foo.singleton_class
       => #<Class:Foo>
  
  Which seems to work just fine.
  =end
  
  
  ---Files--------------------------------
  bug9311-test.diff (568 Bytes)
  
  
  -- 
  http://bugs.ruby-lang.org/
 
 ----------------------------------------
 Bug #9311: module_function breaks on `singleton_class?`
 https://bugs.ruby-lang.org/issues/9311#change-44369
 
 * Author: Chris Heald
 * Status: Open
 * Priority: Normal
 * Assignee: 
 * Category: 
 * Target version: 
 * ruby -v: -
 * Backport: 
 ----------------------------------------
 =begin
 When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:
 
     [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
     => [:singleton_class?, :singleton_class]
     [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
     NoMethodError: undefined method `method_function' for Sass::Util:Module
     from (pry):6:in `<module:Util>'
 
 This is actually pretty trivially reproduced via:
 
     2.1.0 :001 > module Foo
     2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
     2.1.0 :003?>   end
     NameError: undefined method `singleton_class?' for module `Foo'
             from (irb):2:in `module_function'
             from (irb):2:in `block in <module:Foo>'
             from (irb):2:in `each'
             from (irb):2:in `<module:Foo>'
             from (irb):1
             from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'
 
 Now, Sass performs the following:
 
     (Sass::Util.methods - Module.methods).each {|method| module_function method }
 
 This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:
 
     class Class
       private
       def singleton_class?
         ancestors.first != self
       end
     end
 
 This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):
 
     2.1.0 :001 > Module.methods.sort
      => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
     2.1.0 :002 > class Class
     2.1.0 :003?>         private
     2.1.0 :004?>         def singleton_class?
     2.1.0 :005?>             ancestors.first != self
     2.1.0 :006?>           end
     2.1.0 :007?>       end
      => :singleton_class?
     2.1.0 :008 > Module.methods.sort
      => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
      
 Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.
 
 This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:
 
     2.0.0p247 :001 > class Class
     2.0.0p247 :002?>   private
     2.0.0p247 :003?>   def singleton_class
     2.0.0p247 :004?>     false
     2.0.0p247 :005?>     end
     2.0.0p247 :006?>   end
      => nil
     2.0.0p247 :007 > module Foo
     2.0.0p247 :008?>   module_function :singleton_class
     2.0.0p247 :009?>   end
      => Foo
     2.0.0p247 :010 > Foo.singleton_class
      => #<Class:Foo>
 
 Which seems to work just fine.
 =end
 
 
 ---Files--------------------------------
 bug9311-test.diff (568 Bytes)
 
 
 -- 
 http://bugs.ruby-lang.org/

----------------------------------------
Bug #9311: module_function breaks on `singleton_class?`
https://bugs.ruby-lang.org/issues/9311#change-44371

* Author: Chris Heald
* Status: Rejected
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: -
* Backport: 
----------------------------------------
=begin
When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:

    [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
    => [:singleton_class?, :singleton_class]
    [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
    NoMethodError: undefined method `method_function' for Sass::Util:Module
    from (pry):6:in `<module:Util>'

This is actually pretty trivially reproduced via:

    2.1.0 :001 > module Foo
    2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
    2.1.0 :003?>   end
    NameError: undefined method `singleton_class?' for module `Foo'
            from (irb):2:in `module_function'
            from (irb):2:in `block in <module:Foo>'
            from (irb):2:in `each'
            from (irb):2:in `<module:Foo>'
            from (irb):1
            from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'

Now, Sass performs the following:

    (Sass::Util.methods - Module.methods).each {|method| module_function method }

This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:

    class Class
      private
      def singleton_class?
        ancestors.first != self
      end
    end

This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):

    2.1.0 :001 > Module.methods.sort
     => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
    2.1.0 :002 > class Class
    2.1.0 :003?>         private
    2.1.0 :004?>         def singleton_class?
    2.1.0 :005?>             ancestors.first != self
    2.1.0 :006?>           end
    2.1.0 :007?>       end
     => :singleton_class?
    2.1.0 :008 > Module.methods.sort
     => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
     
Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.

This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:

    2.0.0p247 :001 > class Class
    2.0.0p247 :002?>   private
    2.0.0p247 :003?>   def singleton_class
    2.0.0p247 :004?>     false
    2.0.0p247 :005?>     end
    2.0.0p247 :006?>   end
     => nil
    2.0.0p247 :007 > module Foo
    2.0.0p247 :008?>   module_function :singleton_class
    2.0.0p247 :009?>   end
     => Foo
    2.0.0p247 :010 > Foo.singleton_class
     => #<Class:Foo>

Which seems to work just fine.
=end


---Files--------------------------------
bug9311-test.diff (568 Bytes)


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:59799] [ruby-trunk - Bug #9311] module_function breaks on `singleton_class?`
       [not found] <redmine.issue-9311.20131228033823@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2014-01-16  0:08 ` [ruby-core:59798] [ruby-trunk - Bug #9311] " ruby
@ 2014-01-16  0:08 ` nobu
  2014-01-16  0:17 ` [ruby-core:59800] " ruby
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: nobu @ 2014-01-16  0:08 UTC (permalink / raw
  To: ruby-core

Issue #9311 has been updated by Nobuyoshi Nakada.


 Issue #9311 has been updated by Nobuyoshi Nakada.
 
 Status changed from Open to Rejected
 
 `Module.singleton_class?` is a method of `Module`, not defined in `Module` instances.
 Other `singleton_`* methods are defined in `Kernel` as instance methods.
 
 ----------------------------------------
 Bug #9311: module_function breaks on `singleton_class?`
 https://bugs.ruby-lang.org/issues/9311#change-44370
 
 * Author: Chris Heald
 * Status: Rejected
 * Priority: Normal
 * Assignee: 
 * Category: 
 * Target version: 
 * ruby -v: -
 * Backport: 
 ----------------------------------------
 =begin
 When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:
 
     [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
     => [:singleton_class?, :singleton_class]
     [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
     NoMethodError: undefined method `method_function' for Sass::Util:Module
     from (pry):6:in `<module:Util>'
 
 This is actually pretty trivially reproduced via:
 
     2.1.0 :001 > module Foo
     2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
     2.1.0 :003?>   end
     NameError: undefined method `singleton_class?' for module `Foo'
             from (irb):2:in `module_function'
             from (irb):2:in `block in <module:Foo>'
             from (irb):2:in `each'
             from (irb):2:in `<module:Foo>'
             from (irb):1
             from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'
 
 Now, Sass performs the following:
 
     (Sass::Util.methods - Module.methods).each {|method| module_function method }
 
 This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:
 
     class Class
       private
       def singleton_class?
         ancestors.first != self
       end
     end
 
 This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):
 
     2.1.0 :001 > Module.methods.sort
      => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
     2.1.0 :002 > class Class
     2.1.0 :003?>         private
     2.1.0 :004?>         def singleton_class?
     2.1.0 :005?>             ancestors.first != self
     2.1.0 :006?>           end
     2.1.0 :007?>       end
      => :singleton_class?
     2.1.0 :008 > Module.methods.sort
      => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
      
 Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.
 
 This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:
 
     2.0.0p247 :001 > class Class
     2.0.0p247 :002?>   private
     2.0.0p247 :003?>   def singleton_class
     2.0.0p247 :004?>     false
     2.0.0p247 :005?>     end
     2.0.0p247 :006?>   end
      => nil
     2.0.0p247 :007 > module Foo
     2.0.0p247 :008?>   module_function :singleton_class
     2.0.0p247 :009?>   end
      => Foo
     2.0.0p247 :010 > Foo.singleton_class
      => #<Class:Foo>
 
 Which seems to work just fine.
 =end
 
 
 ---Files--------------------------------
 bug9311-test.diff (568 Bytes)
 
 
 -- 
 http://bugs.ruby-lang.org/

----------------------------------------
Bug #9311: module_function breaks on `singleton_class?`
https://bugs.ruby-lang.org/issues/9311#change-44372

* Author: Chris Heald
* Status: Rejected
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: -
* Backport: 
----------------------------------------
=begin
When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:

    [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
    => [:singleton_class?, :singleton_class]
    [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
    NoMethodError: undefined method `method_function' for Sass::Util:Module
    from (pry):6:in `<module:Util>'

This is actually pretty trivially reproduced via:

    2.1.0 :001 > module Foo
    2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
    2.1.0 :003?>   end
    NameError: undefined method `singleton_class?' for module `Foo'
            from (irb):2:in `module_function'
            from (irb):2:in `block in <module:Foo>'
            from (irb):2:in `each'
            from (irb):2:in `<module:Foo>'
            from (irb):1
            from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'

Now, Sass performs the following:

    (Sass::Util.methods - Module.methods).each {|method| module_function method }

This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:

    class Class
      private
      def singleton_class?
        ancestors.first != self
      end
    end

This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):

    2.1.0 :001 > Module.methods.sort
     => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
    2.1.0 :002 > class Class
    2.1.0 :003?>         private
    2.1.0 :004?>         def singleton_class?
    2.1.0 :005?>             ancestors.first != self
    2.1.0 :006?>           end
    2.1.0 :007?>       end
     => :singleton_class?
    2.1.0 :008 > Module.methods.sort
     => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
     
Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.

This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:

    2.0.0p247 :001 > class Class
    2.0.0p247 :002?>   private
    2.0.0p247 :003?>   def singleton_class
    2.0.0p247 :004?>     false
    2.0.0p247 :005?>     end
    2.0.0p247 :006?>   end
     => nil
    2.0.0p247 :007 > module Foo
    2.0.0p247 :008?>   module_function :singleton_class
    2.0.0p247 :009?>   end
     => Foo
    2.0.0p247 :010 > Foo.singleton_class
     => #<Class:Foo>

Which seems to work just fine.
=end


---Files--------------------------------
bug9311-test.diff (568 Bytes)


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:59800] [ruby-trunk - Bug #9311] module_function breaks on `singleton_class?`
       [not found] <redmine.issue-9311.20131228033823@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2014-01-16  0:08 ` [ruby-core:59799] " nobu
@ 2014-01-16  0:17 ` ruby
  2014-01-16  0:17 ` [ruby-core:59801] " nobu
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: ruby @ 2014-01-16  0:17 UTC (permalink / raw
  To: ruby-core

Issue #9311 has been updated by Aman Gupta.


 Issue #9311 has been updated by Aman Gupta.
 
 
  Issue #9311 has been updated by Aman Gupta.
  
  ruby -v changed from ruby 2.1.0 to -
  
   Issue #9311 has been updated by Aman Gupta.
   
   File bug9311-test.diff added
   
   Attached regression test for trunk.
   
   ----------------------------------------
   Bug #9311: module_function breaks on `singleton_class?`
   https://bugs.ruby-lang.org/issues/9311#change-44368
   
   * Author: Chris Heald
   * Status: Open
   * Priority: Normal
   * Assignee: 
   * Category: 
   * Target version: 
   * ruby -v: ruby 2.1.0
   * Backport: 
   ----------------------------------------
   =begin
   When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:
   
       [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
       => [:singleton_class?, :singleton_class]
       [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
       NoMethodError: undefined method `method_function' for Sass::Util:Module
       from (pry):6:in `<module:Util>'
   
   This is actually pretty trivially reproduced via:
   
       2.1.0 :001 > module Foo
       2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
       2.1.0 :003?>   end
       NameError: undefined method `singleton_class?' for module `Foo'
               from (irb):2:in `module_function'
               from (irb):2:in `block in <module:Foo>'
               from (irb):2:in `each'
               from (irb):2:in `<module:Foo>'
               from (irb):1
               from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'
   
   Now, Sass performs the following:
   
       (Sass::Util.methods - Module.methods).each {|method| module_function method }
   
   This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:
   
       class Class
         private
         def singleton_class?
           ancestors.first != self
         end
       end
   
   This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):
   
       2.1.0 :001 > Module.methods.sort
        => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
       2.1.0 :002 > class Class
       2.1.0 :003?>         private
       2.1.0 :004?>         def singleton_class?
       2.1.0 :005?>             ancestors.first != self
       2.1.0 :006?>           end
       2.1.0 :007?>       end
        => :singleton_class?
       2.1.0 :008 > Module.methods.sort
        => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
        
   Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.
   
   This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:
   
       2.0.0p247 :001 > class Class
       2.0.0p247 :002?>   private
       2.0.0p247 :003?>   def singleton_class
       2.0.0p247 :004?>     false
       2.0.0p247 :005?>     end
       2.0.0p247 :006?>   end
        => nil
       2.0.0p247 :007 > module Foo
       2.0.0p247 :008?>   module_function :singleton_class
       2.0.0p247 :009?>   end
        => Foo
       2.0.0p247 :010 > Foo.singleton_class
        => #<Class:Foo>
   
   Which seems to work just fine.
   =end
   
   
   ---Files--------------------------------
   bug9311-test.diff (568 Bytes)
   
   
   -- 
   http://bugs.ruby-lang.org/
  
  ----------------------------------------
  Bug #9311: module_function breaks on `singleton_class?`
  https://bugs.ruby-lang.org/issues/9311#change-44369
  
  * Author: Chris Heald
  * Status: Open
  * Priority: Normal
  * Assignee: 
  * Category: 
  * Target version: 
  * ruby -v: -
  * Backport: 
  ----------------------------------------
  =begin
  When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:
  
      [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
      => [:singleton_class?, :singleton_class]
      [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
      NoMethodError: undefined method `method_function' for Sass::Util:Module
      from (pry):6:in `<module:Util>'
  
  This is actually pretty trivially reproduced via:
  
      2.1.0 :001 > module Foo
      2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
      2.1.0 :003?>   end
      NameError: undefined method `singleton_class?' for module `Foo'
              from (irb):2:in `module_function'
              from (irb):2:in `block in <module:Foo>'
              from (irb):2:in `each'
              from (irb):2:in `<module:Foo>'
              from (irb):1
              from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'
  
  Now, Sass performs the following:
  
      (Sass::Util.methods - Module.methods).each {|method| module_function method }
  
  This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:
  
      class Class
        private
        def singleton_class?
          ancestors.first != self
        end
      end
  
  This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):
  
      2.1.0 :001 > Module.methods.sort
       => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
      2.1.0 :002 > class Class
      2.1.0 :003?>         private
      2.1.0 :004?>         def singleton_class?
      2.1.0 :005?>             ancestors.first != self
      2.1.0 :006?>           end
      2.1.0 :007?>       end
       => :singleton_class?
      2.1.0 :008 > Module.methods.sort
       => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
       
  Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.
  
  This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:
  
      2.0.0p247 :001 > class Class
      2.0.0p247 :002?>   private
      2.0.0p247 :003?>   def singleton_class
      2.0.0p247 :004?>     false
      2.0.0p247 :005?>     end
      2.0.0p247 :006?>   end
       => nil
      2.0.0p247 :007 > module Foo
      2.0.0p247 :008?>   module_function :singleton_class
      2.0.0p247 :009?>   end
       => Foo
      2.0.0p247 :010 > Foo.singleton_class
       => #<Class:Foo>
  
  Which seems to work just fine.
  =end
  
  
  ---Files--------------------------------
  bug9311-test.diff (568 Bytes)
  
  
  -- 
  http://bugs.ruby-lang.org/
 
 ----------------------------------------
 Bug #9311: module_function breaks on `singleton_class?`
 https://bugs.ruby-lang.org/issues/9311#change-44371
 
 * Author: Chris Heald
 * Status: Rejected
 * Priority: Normal
 * Assignee: 
 * Category: 
 * Target version: 
 * ruby -v: -
 * Backport: 
 ----------------------------------------
 =begin
 When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:
 
     [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
     => [:singleton_class?, :singleton_class]
     [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
     NoMethodError: undefined method `method_function' for Sass::Util:Module
     from (pry):6:in `<module:Util>'
 
 This is actually pretty trivially reproduced via:
 
     2.1.0 :001 > module Foo
     2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
     2.1.0 :003?>   end
     NameError: undefined method `singleton_class?' for module `Foo'
             from (irb):2:in `module_function'
             from (irb):2:in `block in <module:Foo>'
             from (irb):2:in `each'
             from (irb):2:in `<module:Foo>'
             from (irb):1
             from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'
 
 Now, Sass performs the following:
 
     (Sass::Util.methods - Module.methods).each {|method| module_function method }
 
 This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:
 
     class Class
       private
       def singleton_class?
         ancestors.first != self
       end
     end
 
 This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):
 
     2.1.0 :001 > Module.methods.sort
      => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
     2.1.0 :002 > class Class
     2.1.0 :003?>         private
     2.1.0 :004?>         def singleton_class?
     2.1.0 :005?>             ancestors.first != self
     2.1.0 :006?>           end
     2.1.0 :007?>       end
      => :singleton_class?
     2.1.0 :008 > Module.methods.sort
      => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
      
 Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.
 
 This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:
 
     2.0.0p247 :001 > class Class
     2.0.0p247 :002?>   private
     2.0.0p247 :003?>   def singleton_class
     2.0.0p247 :004?>     false
     2.0.0p247 :005?>     end
     2.0.0p247 :006?>   end
      => nil
     2.0.0p247 :007 > module Foo
     2.0.0p247 :008?>   module_function :singleton_class
     2.0.0p247 :009?>   end
      => Foo
     2.0.0p247 :010 > Foo.singleton_class
      => #<Class:Foo>
 
 Which seems to work just fine.
 =end
 
 
 ---Files--------------------------------
 bug9311-test.diff (568 Bytes)
 
 
 -- 
 http://bugs.ruby-lang.org/

----------------------------------------
Bug #9311: module_function breaks on `singleton_class?`
https://bugs.ruby-lang.org/issues/9311#change-44373

* Author: Chris Heald
* Status: Rejected
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: -
* Backport: 
----------------------------------------
=begin
When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:

    [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
    => [:singleton_class?, :singleton_class]
    [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
    NoMethodError: undefined method `method_function' for Sass::Util:Module
    from (pry):6:in `<module:Util>'

This is actually pretty trivially reproduced via:

    2.1.0 :001 > module Foo
    2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
    2.1.0 :003?>   end
    NameError: undefined method `singleton_class?' for module `Foo'
            from (irb):2:in `module_function'
            from (irb):2:in `block in <module:Foo>'
            from (irb):2:in `each'
            from (irb):2:in `<module:Foo>'
            from (irb):1
            from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'

Now, Sass performs the following:

    (Sass::Util.methods - Module.methods).each {|method| module_function method }

This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:

    class Class
      private
      def singleton_class?
        ancestors.first != self
      end
    end

This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):

    2.1.0 :001 > Module.methods.sort
     => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
    2.1.0 :002 > class Class
    2.1.0 :003?>         private
    2.1.0 :004?>         def singleton_class?
    2.1.0 :005?>             ancestors.first != self
    2.1.0 :006?>           end
    2.1.0 :007?>       end
     => :singleton_class?
    2.1.0 :008 > Module.methods.sort
     => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
     
Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.

This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:

    2.0.0p247 :001 > class Class
    2.0.0p247 :002?>   private
    2.0.0p247 :003?>   def singleton_class
    2.0.0p247 :004?>     false
    2.0.0p247 :005?>     end
    2.0.0p247 :006?>   end
     => nil
    2.0.0p247 :007 > module Foo
    2.0.0p247 :008?>   module_function :singleton_class
    2.0.0p247 :009?>   end
     => Foo
    2.0.0p247 :010 > Foo.singleton_class
     => #<Class:Foo>

Which seems to work just fine.
=end


---Files--------------------------------
bug9311-test.diff (568 Bytes)


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:59801] [ruby-trunk - Bug #9311] module_function breaks on `singleton_class?`
       [not found] <redmine.issue-9311.20131228033823@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2014-01-16  0:17 ` [ruby-core:59800] " ruby
@ 2014-01-16  0:17 ` nobu
  2014-01-16  0:29 ` [ruby-core:59802] " ruby
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: nobu @ 2014-01-16  0:17 UTC (permalink / raw
  To: ruby-core

Issue #9311 has been updated by Nobuyoshi Nakada.


 Issue #9311 has been updated by Nobuyoshi Nakada.
 
 
  Issue #9311 has been updated by Nobuyoshi Nakada.
  
  Status changed from Open to Rejected
  
  `Module.singleton_class?` is a method of `Module`, not defined in `Module` instances.
  Other `singleton_`* methods are defined in `Kernel` as instance methods.
  
  ----------------------------------------
  Bug #9311: module_function breaks on `singleton_class?`
  https://bugs.ruby-lang.org/issues/9311#change-44370
  
  * Author: Chris Heald
  * Status: Rejected
  * Priority: Normal
  * Assignee: 
  * Category: 
  * Target version: 
  * ruby -v: -
  * Backport: 
  ----------------------------------------
  =begin
  When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:
  
      [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
      => [:singleton_class?, :singleton_class]
      [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
      NoMethodError: undefined method `method_function' for Sass::Util:Module
      from (pry):6:in `<module:Util>'
  
  This is actually pretty trivially reproduced via:
  
      2.1.0 :001 > module Foo
      2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
      2.1.0 :003?>   end
      NameError: undefined method `singleton_class?' for module `Foo'
              from (irb):2:in `module_function'
              from (irb):2:in `block in <module:Foo>'
              from (irb):2:in `each'
              from (irb):2:in `<module:Foo>'
              from (irb):1
              from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'
  
  Now, Sass performs the following:
  
      (Sass::Util.methods - Module.methods).each {|method| module_function method }
  
  This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:
  
      class Class
        private
        def singleton_class?
          ancestors.first != self
        end
      end
  
  This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):
  
      2.1.0 :001 > Module.methods.sort
       => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
      2.1.0 :002 > class Class
      2.1.0 :003?>         private
      2.1.0 :004?>         def singleton_class?
      2.1.0 :005?>             ancestors.first != self
      2.1.0 :006?>           end
      2.1.0 :007?>       end
       => :singleton_class?
      2.1.0 :008 > Module.methods.sort
       => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
       
  Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.
  
  This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:
  
      2.0.0p247 :001 > class Class
      2.0.0p247 :002?>   private
      2.0.0p247 :003?>   def singleton_class
      2.0.0p247 :004?>     false
      2.0.0p247 :005?>     end
      2.0.0p247 :006?>   end
       => nil
      2.0.0p247 :007 > module Foo
      2.0.0p247 :008?>   module_function :singleton_class
      2.0.0p247 :009?>   end
       => Foo
      2.0.0p247 :010 > Foo.singleton_class
       => #<Class:Foo>
  
  Which seems to work just fine.
  =end
  
  
  ---Files--------------------------------
  bug9311-test.diff (568 Bytes)
  
  
  -- 
  http://bugs.ruby-lang.org/
 
 ----------------------------------------
 Bug #9311: module_function breaks on `singleton_class?`
 https://bugs.ruby-lang.org/issues/9311#change-44372
 
 * Author: Chris Heald
 * Status: Rejected
 * Priority: Normal
 * Assignee: 
 * Category: 
 * Target version: 
 * ruby -v: -
 * Backport: 
 ----------------------------------------
 =begin
 When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:
 
     [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
     => [:singleton_class?, :singleton_class]
     [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
     NoMethodError: undefined method `method_function' for Sass::Util:Module
     from (pry):6:in `<module:Util>'
 
 This is actually pretty trivially reproduced via:
 
     2.1.0 :001 > module Foo
     2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
     2.1.0 :003?>   end
     NameError: undefined method `singleton_class?' for module `Foo'
             from (irb):2:in `module_function'
             from (irb):2:in `block in <module:Foo>'
             from (irb):2:in `each'
             from (irb):2:in `<module:Foo>'
             from (irb):1
             from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'
 
 Now, Sass performs the following:
 
     (Sass::Util.methods - Module.methods).each {|method| module_function method }
 
 This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:
 
     class Class
       private
       def singleton_class?
         ancestors.first != self
       end
     end
 
 This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):
 
     2.1.0 :001 > Module.methods.sort
      => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
     2.1.0 :002 > class Class
     2.1.0 :003?>         private
     2.1.0 :004?>         def singleton_class?
     2.1.0 :005?>             ancestors.first != self
     2.1.0 :006?>           end
     2.1.0 :007?>       end
      => :singleton_class?
     2.1.0 :008 > Module.methods.sort
      => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
      
 Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.
 
 This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:
 
     2.0.0p247 :001 > class Class
     2.0.0p247 :002?>   private
     2.0.0p247 :003?>   def singleton_class
     2.0.0p247 :004?>     false
     2.0.0p247 :005?>     end
     2.0.0p247 :006?>   end
      => nil
     2.0.0p247 :007 > module Foo
     2.0.0p247 :008?>   module_function :singleton_class
     2.0.0p247 :009?>   end
      => Foo
     2.0.0p247 :010 > Foo.singleton_class
      => #<Class:Foo>
 
 Which seems to work just fine.
 =end
 
 
 ---Files--------------------------------
 bug9311-test.diff (568 Bytes)
 
 
 -- 
 http://bugs.ruby-lang.org/

----------------------------------------
Bug #9311: module_function breaks on `singleton_class?`
https://bugs.ruby-lang.org/issues/9311#change-44374

* Author: Chris Heald
* Status: Rejected
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: -
* Backport: 
----------------------------------------
=begin
When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:

    [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
    => [:singleton_class?, :singleton_class]
    [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
    NoMethodError: undefined method `method_function' for Sass::Util:Module
    from (pry):6:in `<module:Util>'

This is actually pretty trivially reproduced via:

    2.1.0 :001 > module Foo
    2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
    2.1.0 :003?>   end
    NameError: undefined method `singleton_class?' for module `Foo'
            from (irb):2:in `module_function'
            from (irb):2:in `block in <module:Foo>'
            from (irb):2:in `each'
            from (irb):2:in `<module:Foo>'
            from (irb):1
            from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'

Now, Sass performs the following:

    (Sass::Util.methods - Module.methods).each {|method| module_function method }

This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:

    class Class
      private
      def singleton_class?
        ancestors.first != self
      end
    end

This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):

    2.1.0 :001 > Module.methods.sort
     => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
    2.1.0 :002 > class Class
    2.1.0 :003?>         private
    2.1.0 :004?>         def singleton_class?
    2.1.0 :005?>             ancestors.first != self
    2.1.0 :006?>           end
    2.1.0 :007?>       end
     => :singleton_class?
    2.1.0 :008 > Module.methods.sort
     => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
     
Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.

This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:

    2.0.0p247 :001 > class Class
    2.0.0p247 :002?>   private
    2.0.0p247 :003?>   def singleton_class
    2.0.0p247 :004?>     false
    2.0.0p247 :005?>     end
    2.0.0p247 :006?>   end
     => nil
    2.0.0p247 :007 > module Foo
    2.0.0p247 :008?>   module_function :singleton_class
    2.0.0p247 :009?>   end
     => Foo
    2.0.0p247 :010 > Foo.singleton_class
     => #<Class:Foo>

Which seems to work just fine.
=end


---Files--------------------------------
bug9311-test.diff (568 Bytes)


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:59802] [ruby-trunk - Bug #9311] module_function breaks on `singleton_class?`
       [not found] <redmine.issue-9311.20131228033823@ruby-lang.org>
                   ` (7 preceding siblings ...)
  2014-01-16  0:17 ` [ruby-core:59801] " nobu
@ 2014-01-16  0:29 ` ruby
  2014-01-16  0:35 ` [ruby-core:59803] " ruby
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 12+ messages in thread
From: ruby @ 2014-01-16  0:29 UTC (permalink / raw
  To: ruby-core

Issue #9311 has been updated by Aman Gupta.


> This causes singleton_class? to no longer show in the Module.methods list (I suspect because of the new method cache invalidation stuff?):

This has nothing to do with method cache, but is instead caused by ActiveSupport marking :singleton_class? as private.

    >> Module.methods.include?(:singleton_class?)
    => true
    
    >> class Class; def singleton_class?() super end; end
    >> Module.methods.include?(:singleton_class?)
    => true
    
    >> class Class; private :singleton_class?; end
    >> Module.methods.include?(:singleton_class?)
    => false


----------------------------------------
Bug #9311: module_function breaks on `singleton_class?`
https://bugs.ruby-lang.org/issues/9311#change-44375

* Author: Chris Heald
* Status: Rejected
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: -
* Backport: 
----------------------------------------
=begin
When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:

    [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
    => [:singleton_class?, :singleton_class]
    [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
    NoMethodError: undefined method `method_function' for Sass::Util:Module
    from (pry):6:in `<module:Util>'

This is actually pretty trivially reproduced via:

    2.1.0 :001 > module Foo
    2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
    2.1.0 :003?>   end
    NameError: undefined method `singleton_class?' for module `Foo'
            from (irb):2:in `module_function'
            from (irb):2:in `block in <module:Foo>'
            from (irb):2:in `each'
            from (irb):2:in `<module:Foo>'
            from (irb):1
            from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'

Now, Sass performs the following:

    (Sass::Util.methods - Module.methods).each {|method| module_function method }

This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:

    class Class
      private
      def singleton_class?
        ancestors.first != self
      end
    end

This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):

    2.1.0 :001 > Module.methods.sort
     => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
    2.1.0 :002 > class Class
    2.1.0 :003?>         private
    2.1.0 :004?>         def singleton_class?
    2.1.0 :005?>             ancestors.first != self
    2.1.0 :006?>           end
    2.1.0 :007?>       end
     => :singleton_class?
    2.1.0 :008 > Module.methods.sort
     => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
     
Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.

This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:

    2.0.0p247 :001 > class Class
    2.0.0p247 :002?>   private
    2.0.0p247 :003?>   def singleton_class
    2.0.0p247 :004?>     false
    2.0.0p247 :005?>     end
    2.0.0p247 :006?>   end
     => nil
    2.0.0p247 :007 > module Foo
    2.0.0p247 :008?>   module_function :singleton_class
    2.0.0p247 :009?>   end
     => Foo
    2.0.0p247 :010 > Foo.singleton_class
     => #<Class:Foo>

Which seems to work just fine.
=end


---Files--------------------------------
bug9311-test.diff (568 Bytes)


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:59803] [ruby-trunk - Bug #9311] module_function breaks on `singleton_class?`
       [not found] <redmine.issue-9311.20131228033823@ruby-lang.org>
                   ` (8 preceding siblings ...)
  2014-01-16  0:29 ` [ruby-core:59802] " ruby
@ 2014-01-16  0:35 ` ruby
  2014-01-16  0:35 ` [ruby-core:59804] " nobu
  2014-01-16  0:35 ` [ruby-core:59805] " ruby
  11 siblings, 0 replies; 12+ messages in thread
From: ruby @ 2014-01-16  0:35 UTC (permalink / raw
  To: ruby-core

Issue #9311 has been updated by Aman Gupta.


 Issue #9311 has been updated by Aman Gupta.
 
 
  Issue #9311 has been updated by Aman Gupta.
  
  
   Issue #9311 has been updated by Aman Gupta.
   
   ruby -v changed from ruby 2.1.0 to -
   
    Issue #9311 has been updated by Aman Gupta.
    
    File bug9311-test.diff added
    
    Attached regression test for trunk.
    
    ----------------------------------------
    Bug #9311: module_function breaks on `singleton_class?`
    https://bugs.ruby-lang.org/issues/9311#change-44368
    
    * Author: Chris Heald
    * Status: Open
    * Priority: Normal
    * Assignee: 
    * Category: 
    * Target version: 
    * ruby -v: ruby 2.1.0
    * Backport: 
    ----------------------------------------
    =begin
    When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:
    
        [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
        => [:singleton_class?, :singleton_class]
        [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
        NoMethodError: undefined method `method_function' for Sass::Util:Module
        from (pry):6:in `<module:Util>'
    
    This is actually pretty trivially reproduced via:
    
        2.1.0 :001 > module Foo
        2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
        2.1.0 :003?>   end
        NameError: undefined method `singleton_class?' for module `Foo'
                from (irb):2:in `module_function'
                from (irb):2:in `block in <module:Foo>'
                from (irb):2:in `each'
                from (irb):2:in `<module:Foo>'
                from (irb):1
                from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'
    
    Now, Sass performs the following:
    
        (Sass::Util.methods - Module.methods).each {|method| module_function method }
    
    This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:
    
        class Class
          private
          def singleton_class?
            ancestors.first != self
          end
        end
    
    This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):
    
        2.1.0 :001 > Module.methods.sort
         => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
        2.1.0 :002 > class Class
        2.1.0 :003?>         private
        2.1.0 :004?>         def singleton_class?
        2.1.0 :005?>             ancestors.first != self
        2.1.0 :006?>           end
        2.1.0 :007?>       end
         => :singleton_class?
        2.1.0 :008 > Module.methods.sort
         => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
         
    Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.
    
    This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:
    
        2.0.0p247 :001 > class Class
        2.0.0p247 :002?>   private
        2.0.0p247 :003?>   def singleton_class
        2.0.0p247 :004?>     false
        2.0.0p247 :005?>     end
        2.0.0p247 :006?>   end
         => nil
        2.0.0p247 :007 > module Foo
        2.0.0p247 :008?>   module_function :singleton_class
        2.0.0p247 :009?>   end
         => Foo
        2.0.0p247 :010 > Foo.singleton_class
         => #<Class:Foo>
    
    Which seems to work just fine.
    =end
    
    
    ---Files--------------------------------
    bug9311-test.diff (568 Bytes)
    
    
    -- 
    http://bugs.ruby-lang.org/
   
   ----------------------------------------
   Bug #9311: module_function breaks on `singleton_class?`
   https://bugs.ruby-lang.org/issues/9311#change-44369
   
   * Author: Chris Heald
   * Status: Open
   * Priority: Normal
   * Assignee: 
   * Category: 
   * Target version: 
   * ruby -v: -
   * Backport: 
   ----------------------------------------
   =begin
   When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:
   
       [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
       => [:singleton_class?, :singleton_class]
       [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
       NoMethodError: undefined method `method_function' for Sass::Util:Module
       from (pry):6:in `<module:Util>'
   
   This is actually pretty trivially reproduced via:
   
       2.1.0 :001 > module Foo
       2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
       2.1.0 :003?>   end
       NameError: undefined method `singleton_class?' for module `Foo'
               from (irb):2:in `module_function'
               from (irb):2:in `block in <module:Foo>'
               from (irb):2:in `each'
               from (irb):2:in `<module:Foo>'
               from (irb):1
               from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'
   
   Now, Sass performs the following:
   
       (Sass::Util.methods - Module.methods).each {|method| module_function method }
   
   This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:
   
       class Class
         private
         def singleton_class?
           ancestors.first != self
         end
       end
   
   This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):
   
       2.1.0 :001 > Module.methods.sort
        => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
       2.1.0 :002 > class Class
       2.1.0 :003?>         private
       2.1.0 :004?>         def singleton_class?
       2.1.0 :005?>             ancestors.first != self
       2.1.0 :006?>           end
       2.1.0 :007?>       end
        => :singleton_class?
       2.1.0 :008 > Module.methods.sort
        => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
        
   Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.
   
   This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:
   
       2.0.0p247 :001 > class Class
       2.0.0p247 :002?>   private
       2.0.0p247 :003?>   def singleton_class
       2.0.0p247 :004?>     false
       2.0.0p247 :005?>     end
       2.0.0p247 :006?>   end
        => nil
       2.0.0p247 :007 > module Foo
       2.0.0p247 :008?>   module_function :singleton_class
       2.0.0p247 :009?>   end
        => Foo
       2.0.0p247 :010 > Foo.singleton_class
        => #<Class:Foo>
   
   Which seems to work just fine.
   =end
   
   
   ---Files--------------------------------
   bug9311-test.diff (568 Bytes)
   
   
   -- 
   http://bugs.ruby-lang.org/
  
  ----------------------------------------
  Bug #9311: module_function breaks on `singleton_class?`
  https://bugs.ruby-lang.org/issues/9311#change-44371
  
  * Author: Chris Heald
  * Status: Rejected
  * Priority: Normal
  * Assignee: 
  * Category: 
  * Target version: 
  * ruby -v: -
  * Backport: 
  ----------------------------------------
  =begin
  When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:
  
      [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
      => [:singleton_class?, :singleton_class]
      [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
      NoMethodError: undefined method `method_function' for Sass::Util:Module
      from (pry):6:in `<module:Util>'
  
  This is actually pretty trivially reproduced via:
  
      2.1.0 :001 > module Foo
      2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
      2.1.0 :003?>   end
      NameError: undefined method `singleton_class?' for module `Foo'
              from (irb):2:in `module_function'
              from (irb):2:in `block in <module:Foo>'
              from (irb):2:in `each'
              from (irb):2:in `<module:Foo>'
              from (irb):1
              from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'
  
  Now, Sass performs the following:
  
      (Sass::Util.methods - Module.methods).each {|method| module_function method }
  
  This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:
  
      class Class
        private
        def singleton_class?
          ancestors.first != self
        end
      end
  
  This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):
  
      2.1.0 :001 > Module.methods.sort
       => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
      2.1.0 :002 > class Class
      2.1.0 :003?>         private
      2.1.0 :004?>         def singleton_class?
      2.1.0 :005?>             ancestors.first != self
      2.1.0 :006?>           end
      2.1.0 :007?>       end
       => :singleton_class?
      2.1.0 :008 > Module.methods.sort
       => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
       
  Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.
  
  This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:
  
      2.0.0p247 :001 > class Class
      2.0.0p247 :002?>   private
      2.0.0p247 :003?>   def singleton_class
      2.0.0p247 :004?>     false
      2.0.0p247 :005?>     end
      2.0.0p247 :006?>   end
       => nil
      2.0.0p247 :007 > module Foo
      2.0.0p247 :008?>   module_function :singleton_class
      2.0.0p247 :009?>   end
       => Foo
      2.0.0p247 :010 > Foo.singleton_class
       => #<Class:Foo>
  
  Which seems to work just fine.
  =end
  
  
  ---Files--------------------------------
  bug9311-test.diff (568 Bytes)
  
  
  -- 
  http://bugs.ruby-lang.org/
 
 ----------------------------------------
 Bug #9311: module_function breaks on `singleton_class?`
 https://bugs.ruby-lang.org/issues/9311#change-44373
 
 * Author: Chris Heald
 * Status: Rejected
 * Priority: Normal
 * Assignee: 
 * Category: 
 * Target version: 
 * ruby -v: -
 * Backport: 
 ----------------------------------------
 =begin
 When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:
 
     [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
     => [:singleton_class?, :singleton_class]
     [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
     NoMethodError: undefined method `method_function' for Sass::Util:Module
     from (pry):6:in `<module:Util>'
 
 This is actually pretty trivially reproduced via:
 
     2.1.0 :001 > module Foo
     2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
     2.1.0 :003?>   end
     NameError: undefined method `singleton_class?' for module `Foo'
             from (irb):2:in `module_function'
             from (irb):2:in `block in <module:Foo>'
             from (irb):2:in `each'
             from (irb):2:in `<module:Foo>'
             from (irb):1
             from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'
 
 Now, Sass performs the following:
 
     (Sass::Util.methods - Module.methods).each {|method| module_function method }
 
 This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:
 
     class Class
       private
       def singleton_class?
         ancestors.first != self
       end
     end
 
 This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):
 
     2.1.0 :001 > Module.methods.sort
      => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
     2.1.0 :002 > class Class
     2.1.0 :003?>         private
     2.1.0 :004?>         def singleton_class?
     2.1.0 :005?>             ancestors.first != self
     2.1.0 :006?>           end
     2.1.0 :007?>       end
      => :singleton_class?
     2.1.0 :008 > Module.methods.sort
      => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
      
 Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.
 
 This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:
 
     2.0.0p247 :001 > class Class
     2.0.0p247 :002?>   private
     2.0.0p247 :003?>   def singleton_class
     2.0.0p247 :004?>     false
     2.0.0p247 :005?>     end
     2.0.0p247 :006?>   end
      => nil
     2.0.0p247 :007 > module Foo
     2.0.0p247 :008?>   module_function :singleton_class
     2.0.0p247 :009?>   end
      => Foo
     2.0.0p247 :010 > Foo.singleton_class
      => #<Class:Foo>
 
 Which seems to work just fine.
 =end
 
 
 ---Files--------------------------------
 bug9311-test.diff (568 Bytes)
 
 
 -- 
 http://bugs.ruby-lang.org/

----------------------------------------
Bug #9311: module_function breaks on `singleton_class?`
https://bugs.ruby-lang.org/issues/9311#change-44376

* Author: Chris Heald
* Status: Rejected
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: -
* Backport: 
----------------------------------------
=begin
When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:

    [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
    => [:singleton_class?, :singleton_class]
    [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
    NoMethodError: undefined method `method_function' for Sass::Util:Module
    from (pry):6:in `<module:Util>'

This is actually pretty trivially reproduced via:

    2.1.0 :001 > module Foo
    2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
    2.1.0 :003?>   end
    NameError: undefined method `singleton_class?' for module `Foo'
            from (irb):2:in `module_function'
            from (irb):2:in `block in <module:Foo>'
            from (irb):2:in `each'
            from (irb):2:in `<module:Foo>'
            from (irb):1
            from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'

Now, Sass performs the following:

    (Sass::Util.methods - Module.methods).each {|method| module_function method }

This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:

    class Class
      private
      def singleton_class?
        ancestors.first != self
      end
    end

This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):

    2.1.0 :001 > Module.methods.sort
     => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
    2.1.0 :002 > class Class
    2.1.0 :003?>         private
    2.1.0 :004?>         def singleton_class?
    2.1.0 :005?>             ancestors.first != self
    2.1.0 :006?>           end
    2.1.0 :007?>       end
     => :singleton_class?
    2.1.0 :008 > Module.methods.sort
     => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
     
Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.

This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:

    2.0.0p247 :001 > class Class
    2.0.0p247 :002?>   private
    2.0.0p247 :003?>   def singleton_class
    2.0.0p247 :004?>     false
    2.0.0p247 :005?>     end
    2.0.0p247 :006?>   end
     => nil
    2.0.0p247 :007 > module Foo
    2.0.0p247 :008?>   module_function :singleton_class
    2.0.0p247 :009?>   end
     => Foo
    2.0.0p247 :010 > Foo.singleton_class
     => #<Class:Foo>

Which seems to work just fine.
=end


---Files--------------------------------
bug9311-test.diff (568 Bytes)


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:59804] [ruby-trunk - Bug #9311] module_function breaks on `singleton_class?`
       [not found] <redmine.issue-9311.20131228033823@ruby-lang.org>
                   ` (9 preceding siblings ...)
  2014-01-16  0:35 ` [ruby-core:59803] " ruby
@ 2014-01-16  0:35 ` nobu
  2014-01-16  0:35 ` [ruby-core:59805] " ruby
  11 siblings, 0 replies; 12+ messages in thread
From: nobu @ 2014-01-16  0:35 UTC (permalink / raw
  To: ruby-core

Issue #9311 has been updated by Nobuyoshi Nakada.


 Issue #9311 has been updated by Nobuyoshi Nakada.
 
 
  Issue #9311 has been updated by Nobuyoshi Nakada.
  
  
   Issue #9311 has been updated by Nobuyoshi Nakada.
   
   Status changed from Open to Rejected
   
   `Module.singleton_class?` is a method of `Module`, not defined in `Module` instances.
   Other `singleton_`* methods are defined in `Kernel` as instance methods.
   
   ----------------------------------------
   Bug #9311: module_function breaks on `singleton_class?`
   https://bugs.ruby-lang.org/issues/9311#change-44370
   
   * Author: Chris Heald
   * Status: Rejected
   * Priority: Normal
   * Assignee: 
   * Category: 
   * Target version: 
   * ruby -v: -
   * Backport: 
   ----------------------------------------
   =begin
   When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:
   
       [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
       => [:singleton_class?, :singleton_class]
       [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
       NoMethodError: undefined method `method_function' for Sass::Util:Module
       from (pry):6:in `<module:Util>'
   
   This is actually pretty trivially reproduced via:
   
       2.1.0 :001 > module Foo
       2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
       2.1.0 :003?>   end
       NameError: undefined method `singleton_class?' for module `Foo'
               from (irb):2:in `module_function'
               from (irb):2:in `block in <module:Foo>'
               from (irb):2:in `each'
               from (irb):2:in `<module:Foo>'
               from (irb):1
               from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'
   
   Now, Sass performs the following:
   
       (Sass::Util.methods - Module.methods).each {|method| module_function method }
   
   This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:
   
       class Class
         private
         def singleton_class?
           ancestors.first != self
         end
       end
   
   This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):
   
       2.1.0 :001 > Module.methods.sort
        => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
       2.1.0 :002 > class Class
       2.1.0 :003?>         private
       2.1.0 :004?>         def singleton_class?
       2.1.0 :005?>             ancestors.first != self
       2.1.0 :006?>           end
       2.1.0 :007?>       end
        => :singleton_class?
       2.1.0 :008 > Module.methods.sort
        => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
        
   Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.
   
   This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:
   
       2.0.0p247 :001 > class Class
       2.0.0p247 :002?>   private
       2.0.0p247 :003?>   def singleton_class
       2.0.0p247 :004?>     false
       2.0.0p247 :005?>     end
       2.0.0p247 :006?>   end
        => nil
       2.0.0p247 :007 > module Foo
       2.0.0p247 :008?>   module_function :singleton_class
       2.0.0p247 :009?>   end
        => Foo
       2.0.0p247 :010 > Foo.singleton_class
        => #<Class:Foo>
   
   Which seems to work just fine.
   =end
   
   
   ---Files--------------------------------
   bug9311-test.diff (568 Bytes)
   
   
   -- 
   http://bugs.ruby-lang.org/
  
  ----------------------------------------
  Bug #9311: module_function breaks on `singleton_class?`
  https://bugs.ruby-lang.org/issues/9311#change-44372
  
  * Author: Chris Heald
  * Status: Rejected
  * Priority: Normal
  * Assignee: 
  * Category: 
  * Target version: 
  * ruby -v: -
  * Backport: 
  ----------------------------------------
  =begin
  When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:
  
      [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
      => [:singleton_class?, :singleton_class]
      [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
      NoMethodError: undefined method `method_function' for Sass::Util:Module
      from (pry):6:in `<module:Util>'
  
  This is actually pretty trivially reproduced via:
  
      2.1.0 :001 > module Foo
      2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
      2.1.0 :003?>   end
      NameError: undefined method `singleton_class?' for module `Foo'
              from (irb):2:in `module_function'
              from (irb):2:in `block in <module:Foo>'
              from (irb):2:in `each'
              from (irb):2:in `<module:Foo>'
              from (irb):1
              from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'
  
  Now, Sass performs the following:
  
      (Sass::Util.methods - Module.methods).each {|method| module_function method }
  
  This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:
  
      class Class
        private
        def singleton_class?
          ancestors.first != self
        end
      end
  
  This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):
  
      2.1.0 :001 > Module.methods.sort
       => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
      2.1.0 :002 > class Class
      2.1.0 :003?>         private
      2.1.0 :004?>         def singleton_class?
      2.1.0 :005?>             ancestors.first != self
      2.1.0 :006?>           end
      2.1.0 :007?>       end
       => :singleton_class?
      2.1.0 :008 > Module.methods.sort
       => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
       
  Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.
  
  This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:
  
      2.0.0p247 :001 > class Class
      2.0.0p247 :002?>   private
      2.0.0p247 :003?>   def singleton_class
      2.0.0p247 :004?>     false
      2.0.0p247 :005?>     end
      2.0.0p247 :006?>   end
       => nil
      2.0.0p247 :007 > module Foo
      2.0.0p247 :008?>   module_function :singleton_class
      2.0.0p247 :009?>   end
       => Foo
      2.0.0p247 :010 > Foo.singleton_class
       => #<Class:Foo>
  
  Which seems to work just fine.
  =end
  
  
  ---Files--------------------------------
  bug9311-test.diff (568 Bytes)
  
  
  -- 
  http://bugs.ruby-lang.org/
 
 ----------------------------------------
 Bug #9311: module_function breaks on `singleton_class?`
 https://bugs.ruby-lang.org/issues/9311#change-44374
 
 * Author: Chris Heald
 * Status: Rejected
 * Priority: Normal
 * Assignee: 
 * Category: 
 * Target version: 
 * ruby -v: -
 * Backport: 
 ----------------------------------------
 =begin
 When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:
 
     [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
     => [:singleton_class?, :singleton_class]
     [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
     NoMethodError: undefined method `method_function' for Sass::Util:Module
     from (pry):6:in `<module:Util>'
 
 This is actually pretty trivially reproduced via:
 
     2.1.0 :001 > module Foo
     2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
     2.1.0 :003?>   end
     NameError: undefined method `singleton_class?' for module `Foo'
             from (irb):2:in `module_function'
             from (irb):2:in `block in <module:Foo>'
             from (irb):2:in `each'
             from (irb):2:in `<module:Foo>'
             from (irb):1
             from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'
 
 Now, Sass performs the following:
 
     (Sass::Util.methods - Module.methods).each {|method| module_function method }
 
 This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:
 
     class Class
       private
       def singleton_class?
         ancestors.first != self
       end
     end
 
 This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):
 
     2.1.0 :001 > Module.methods.sort
      => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
     2.1.0 :002 > class Class
     2.1.0 :003?>         private
     2.1.0 :004?>         def singleton_class?
     2.1.0 :005?>             ancestors.first != self
     2.1.0 :006?>           end
     2.1.0 :007?>       end
      => :singleton_class?
     2.1.0 :008 > Module.methods.sort
      => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
      
 Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.
 
 This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:
 
     2.0.0p247 :001 > class Class
     2.0.0p247 :002?>   private
     2.0.0p247 :003?>   def singleton_class
     2.0.0p247 :004?>     false
     2.0.0p247 :005?>     end
     2.0.0p247 :006?>   end
      => nil
     2.0.0p247 :007 > module Foo
     2.0.0p247 :008?>   module_function :singleton_class
     2.0.0p247 :009?>   end
      => Foo
     2.0.0p247 :010 > Foo.singleton_class
      => #<Class:Foo>
 
 Which seems to work just fine.
 =end
 
 
 ---Files--------------------------------
 bug9311-test.diff (568 Bytes)
 
 
 -- 
 http://bugs.ruby-lang.org/

----------------------------------------
Bug #9311: module_function breaks on `singleton_class?`
https://bugs.ruby-lang.org/issues/9311#change-44377

* Author: Chris Heald
* Status: Rejected
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: -
* Backport: 
----------------------------------------
=begin
When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:

    [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
    => [:singleton_class?, :singleton_class]
    [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
    NoMethodError: undefined method `method_function' for Sass::Util:Module
    from (pry):6:in `<module:Util>'

This is actually pretty trivially reproduced via:

    2.1.0 :001 > module Foo
    2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
    2.1.0 :003?>   end
    NameError: undefined method `singleton_class?' for module `Foo'
            from (irb):2:in `module_function'
            from (irb):2:in `block in <module:Foo>'
            from (irb):2:in `each'
            from (irb):2:in `<module:Foo>'
            from (irb):1
            from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'

Now, Sass performs the following:

    (Sass::Util.methods - Module.methods).each {|method| module_function method }

This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:

    class Class
      private
      def singleton_class?
        ancestors.first != self
      end
    end

This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):

    2.1.0 :001 > Module.methods.sort
     => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
    2.1.0 :002 > class Class
    2.1.0 :003?>         private
    2.1.0 :004?>         def singleton_class?
    2.1.0 :005?>             ancestors.first != self
    2.1.0 :006?>           end
    2.1.0 :007?>       end
     => :singleton_class?
    2.1.0 :008 > Module.methods.sort
     => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
     
Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.

This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:

    2.0.0p247 :001 > class Class
    2.0.0p247 :002?>   private
    2.0.0p247 :003?>   def singleton_class
    2.0.0p247 :004?>     false
    2.0.0p247 :005?>     end
    2.0.0p247 :006?>   end
     => nil
    2.0.0p247 :007 > module Foo
    2.0.0p247 :008?>   module_function :singleton_class
    2.0.0p247 :009?>   end
     => Foo
    2.0.0p247 :010 > Foo.singleton_class
     => #<Class:Foo>

Which seems to work just fine.
=end


---Files--------------------------------
bug9311-test.diff (568 Bytes)


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ruby-core:59805] [ruby-trunk - Bug #9311] module_function breaks on `singleton_class?`
       [not found] <redmine.issue-9311.20131228033823@ruby-lang.org>
                   ` (10 preceding siblings ...)
  2014-01-16  0:35 ` [ruby-core:59804] " nobu
@ 2014-01-16  0:35 ` ruby
  11 siblings, 0 replies; 12+ messages in thread
From: ruby @ 2014-01-16  0:35 UTC (permalink / raw
  To: ruby-core

Issue #9311 has been updated by Aman Gupta.


 Issue #9311 has been updated by Aman Gupta.
 
 
 > This causes singleton_class? to no longer show in the Module.methods list (I suspect because of the new method cache invalidation stuff?):
 
 This has nothing to do with method cache, but is instead caused by ActiveSupport marking :singleton_class? as private.
 
     >> Module.methods.include?(:singleton_class?)
     => true
     
     >> class Class; def singleton_class?() super end; end
     >> Module.methods.include?(:singleton_class?)
     => true
     
     >> class Class; private :singleton_class?; end
     >> Module.methods.include?(:singleton_class?)
     => false
 
 
 ----------------------------------------
 Bug #9311: module_function breaks on `singleton_class?`
 https://bugs.ruby-lang.org/issues/9311#change-44375
 
 * Author: Chris Heald
 * Status: Rejected
 * Priority: Normal
 * Assignee: 
 * Category: 
 * Target version: 
 * ruby -v: -
 * Backport: 
 ----------------------------------------
 =begin
 When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:
 
     [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
     => [:singleton_class?, :singleton_class]
     [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
     NoMethodError: undefined method `method_function' for Sass::Util:Module
     from (pry):6:in `<module:Util>'
 
 This is actually pretty trivially reproduced via:
 
     2.1.0 :001 > module Foo
     2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
     2.1.0 :003?>   end
     NameError: undefined method `singleton_class?' for module `Foo'
             from (irb):2:in `module_function'
             from (irb):2:in `block in <module:Foo>'
             from (irb):2:in `each'
             from (irb):2:in `<module:Foo>'
             from (irb):1
             from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'
 
 Now, Sass performs the following:
 
     (Sass::Util.methods - Module.methods).each {|method| module_function method }
 
 This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:
 
     class Class
       private
       def singleton_class?
         ancestors.first != self
       end
     end
 
 This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):
 
     2.1.0 :001 > Module.methods.sort
      => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
     2.1.0 :002 > class Class
     2.1.0 :003?>         private
     2.1.0 :004?>         def singleton_class?
     2.1.0 :005?>             ancestors.first != self
     2.1.0 :006?>           end
     2.1.0 :007?>       end
      => :singleton_class?
     2.1.0 :008 > Module.methods.sort
      => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
      
 Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.
 
 This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:
 
     2.0.0p247 :001 > class Class
     2.0.0p247 :002?>   private
     2.0.0p247 :003?>   def singleton_class
     2.0.0p247 :004?>     false
     2.0.0p247 :005?>     end
     2.0.0p247 :006?>   end
      => nil
     2.0.0p247 :007 > module Foo
     2.0.0p247 :008?>   module_function :singleton_class
     2.0.0p247 :009?>   end
      => Foo
     2.0.0p247 :010 > Foo.singleton_class
      => #<Class:Foo>
 
 Which seems to work just fine.
 =end
 
 
 ---Files--------------------------------
 bug9311-test.diff (568 Bytes)
 
 
 -- 
 http://bugs.ruby-lang.org/

----------------------------------------
Bug #9311: module_function breaks on `singleton_class?`
https://bugs.ruby-lang.org/issues/9311#change-44378

* Author: Chris Heald
* Status: Rejected
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: -
* Backport: 
----------------------------------------
=begin
When trying to use Sass 3.3.0-rc2 with Rails 3.x, an error similar to the one below is produced:

    [6] pry(Sass::Util)> Sass::Util.methods.grep /singleton_class/
    => [:singleton_class?, :singleton_class]
    [7] pry(Sass::Util)> Sass::Util.method_function :singleton_class?
    NoMethodError: undefined method `method_function' for Sass::Util:Module
    from (pry):6:in `<module:Util>'

This is actually pretty trivially reproduced via:

    2.1.0 :001 > module Foo
    2.1.0 :002?>   methods.grep(/singleton/).each {|x| module_function x }
    2.1.0 :003?>   end
    NameError: undefined method `singleton_class?' for module `Foo'
            from (irb):2:in `module_function'
            from (irb):2:in `block in <module:Foo>'
            from (irb):2:in `each'
            from (irb):2:in `<module:Foo>'
            from (irb):1
            from /usr/local/rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'

Now, Sass performs the following:

    (Sass::Util.methods - Module.methods).each {|method| module_function method }

This succeeds if you don't include ActiveSupport, but ActiveSupport extends Class with the following:

    class Class
      private
      def singleton_class?
        ancestors.first != self
      end
    end

This causes `singleton_class?` to no longer show in the `Module.methods` list (I suspect because of the new method cache invalidation stuff?):

    2.1.0 :001 > Module.methods.sort
     => [... :singleton_class, :singleton_class?, :singleton_method, :singleton_methods, :superclass, ...]
    2.1.0 :002 > class Class
    2.1.0 :003?>         private
    2.1.0 :004?>         def singleton_class?
    2.1.0 :005?>             ancestors.first != self
    2.1.0 :006?>           end
    2.1.0 :007?>       end
     => :singleton_class?
    2.1.0 :008 > Module.methods.sort
     => [... :singleton_class, :singleton_method, :singleton_methods, :superclass, ...]
     
Since it's no longer in the Module.methods list, Sass attempts to `module_function` it and the whole thing blows up.

This is fixable in both Sass and ActiveSupport (which I'll file tickets for), but it feels like this is a Ruby bug. Doing something similar in 2.0 (which doesn't have `singleton_class?`) results in the following:

    2.0.0p247 :001 > class Class
    2.0.0p247 :002?>   private
    2.0.0p247 :003?>   def singleton_class
    2.0.0p247 :004?>     false
    2.0.0p247 :005?>     end
    2.0.0p247 :006?>   end
     => nil
    2.0.0p247 :007 > module Foo
    2.0.0p247 :008?>   module_function :singleton_class
    2.0.0p247 :009?>   end
     => Foo
    2.0.0p247 :010 > Foo.singleton_class
     => #<Class:Foo>

Which seems to work just fine.
=end


---Files--------------------------------
bug9311-test.diff (568 Bytes)


-- 
http://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-01-16  0:51 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-9311.20131228033823@ruby-lang.org>
2014-01-13  2:44 ` [ruby-core:59730] [ruby-trunk - Bug #9311] module_function breaks on `singleton_class?` Hiroshi, SHIBATA
2014-01-15 23:50 ` [ruby-core:59795] " ruby
2014-01-15 23:56 ` [ruby-core:59796] " ruby
2014-01-16  0:06 ` [ruby-core:59797] [ruby-trunk - Bug #9311] [Rejected] " nobu
2014-01-16  0:08 ` [ruby-core:59798] [ruby-trunk - Bug #9311] " ruby
2014-01-16  0:08 ` [ruby-core:59799] " nobu
2014-01-16  0:17 ` [ruby-core:59800] " ruby
2014-01-16  0:17 ` [ruby-core:59801] " nobu
2014-01-16  0:29 ` [ruby-core:59802] " ruby
2014-01-16  0:35 ` [ruby-core:59803] " ruby
2014-01-16  0:35 ` [ruby-core:59804] " nobu
2014-01-16  0:35 ` [ruby-core:59805] " ruby

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).