From: alex.wayfer@... Date: 2019-12-05T13:34:09+00:00 Subject: [ruby-core:96120] [Ruby master Bug#16403] Unavailable protected methods through `Symbol#to_proc` Issue #16403 has been reported by AlexWayfer (Alexander Popov). ---------------------------------------- Bug #16403: Unavailable protected methods through `Symbol#to_proc` https://bugs.ruby-lang.org/issues/16403 * Author: AlexWayfer (Alexander Popov) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- Hello! I've faced with a bug (I guess): ``` ruby # protected.rb # frozen_string_literal: true class Foo def initialize(text, *children) @text = text @children = children end def via_each @children.reduce(text) do |result, child| result + child.text end end def via_map text + @children.map(&:text).reduce(:+) end protected attr_reader :text end child1 = Foo.new('Alexander ') child2 = Foo.new('Popov') foo = Foo.new('Hello ', child1, child2) puts foo.via_each puts foo.via_map ``` Output: ``` Hello Alexander Popov Traceback (most recent call last): 2: from protected.rb:31:in `
' 1: from protected.rb:16:in `via_map' protected.rb:16:in `map': protected method `text' called for # (NoMethodError) ``` -- https://bugs.ruby-lang.org/ Unsubscribe: