Project

General

Profile

Actions

Bug #11246

closed

refine block doesn't respect "lexical" refinement information

Bug #11246: refine block doesn't respect "lexical" refinement information

Added by ko1 (Koichi Sasada) over 10 years ago. Updated over 10 years ago.

Status:
Rejected
Target version:
-
ruby -v:
ruby 2.3dev
[ruby-core:69516]

Description

The following program making two refinements refine class C.

class C
  def foo
    p C
  end
end

module R1
  refine C do
    def foo
      p R1
      super
    end
  end
end

using R1 # 1

module R2
  using R1 # 2

  refine C do
    # using R1 # 3

    def bar
      C.new.foo
    end
  end
end

using R2

C.new.bar

Without using R1 # 3, C#foo was called in R2::C#bar.

By using R1 #1 and #2, we declared that this lexical scope should use R1. However, it seems that this declaration is ignored.

Is it an intentional behavior?

Updated by ko1 (Koichi Sasada) over 10 years ago Actions #1 [ruby-core:69517]

  • Description updated (diff)

Updated by shugo (Shugo Maeda) over 10 years ago Actions #2 [ruby-core:69723]

  • Status changed from Open to Rejected

Koichi Sasada wrote:

The following program making two refinements refine class C.

class C
  def foo
    p C
  end
end

module R1
  refine C do
    def foo
      p R1
      super
    end
  end
end

using R1 # 1

module R2
  using R1 # 2

  refine C do
    # using R1 # 3

    def bar
      C.new.foo
    end
  end
end

using R2

C.new.bar

Without using R1 # 3, C#foo was called in R2::C#bar.

By using R1 #1 and #2, we declared that this lexical scope should use R1. However, it seems that this declaration is ignored.

Is it an intentional behavior?

It's intentional.

In refine blocks of a module X, all refinements defined in X are activated, and other refinements previously activated are deactivated.

Actions

Also available in: PDF Atom