Project

General

Profile

Actions

Bug #11096

closed

'private' access control bypassed when ||= is used

Added by sokol (Piotr Sokołowski) almost 9 years ago. Updated almost 9 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0dev (2015-04-24 trunk 50382) [x86_64-linux]
[ruby-core:68984]

Description

Problematic code

class A
  def aa
    self.bb ||= 0
  end

  private

  def bb
    1
  end
end

A.new.aa

On 2.0 and 2.1 this produces 'NoMethodError: private method `bb' called for'. But since 2.2 this works and return '1'. Checked also on ruby-head from rvm.
This is similar #9907 but this allows to execute private methods by pretending that setter might be used.


Related issues 2 (0 open2 closed)

Related to Ruby master - Bug #9907: Abbreviated method assignment with private attr_writer/attr_reader does not work.ClosedActions
Related to Ruby master - Bug #10060: private attr_accessor and NoMethodErrorClosed07/18/2014Actions

Updated by nobu (Nobuyoshi Nakada) almost 9 years ago

  • Description updated (diff)
  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED

Updated by nobu (Nobuyoshi Nakada) almost 9 years ago

Seems opposite of [Bug #10060].

Actions #3

Updated by nobu (Nobuyoshi Nakada) almost 9 years ago

  • Status changed from Open to Closed

Applied in changeset r50408.


compile.c: disallow private readers

  • compile.c (iseq_compile_each): revert r46873 and r46875, not to
    allow to execute private readers by pretending op assign.
    [ruby-core:68984] [Bug #11096]
Actions #4

Updated by nagachika (Tomoyuki Chikanaga) almost 9 years ago

  • Backport changed from 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONE

Backorted into ruby_2_2 branch at r50562.

Actions #5

Updated by nobu (Nobuyoshi Nakada) almost 7 years ago

  • Related to Bug #9907: Abbreviated method assignment with private attr_writer/attr_reader does not work. added
Actions #6

Updated by nobu (Nobuyoshi Nakada) almost 7 years ago

  • Related to Bug #10060: private attr_accessor and NoMethodError added
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0