[#66126] Creation/Conversion methods/functions table for Ruby types — SASADA Koichi <ko1@...>
Hi,
5 messages
2014/11/07
[#66248] [ruby-trunk - Feature #10423] [PATCH] opt_str_lit*: avoid literal string allocations — normalperson@...
Issue #10423 has been updated by Eric Wong.
3 messages
2014/11/13
[#66595] [ruby-trunk - Bug #10557] [Open] Block not given when the argument is a string — bartosz@...
Issue #10557 has been reported by Bartosz Kopinski.
3 messages
2014/11/30
[ruby-core:66138] [ruby-trunk - Bug #9907] Abbreviated method assignment with private attr_writer/attr_reader does not work.
From:
headius@...
Date:
2014-11-07 18:13:47 UTC
List:
ruby-core #66138
Issue #9907 has been updated by Charles Nutter. The following two pieces of code should both work, since they both do the same thing. VM-level exceptions *hurt* understandability, and it should come as a surprise to any Rubyist that self.foo+= can skip visibility checks but self.foo can't. self.foo += 1 # ok AND self.foo = self.foo + 1 # visibility error The first line essentially expands to the second line. The first line works, the second line doesn't. That makes no sense to me. Also, what if I had "self.foo += 1" (working fine after this bug) and later wanted to expand the logic to add some additional operations. It would break, and I wouldn't understand why. self.foo = self.foo * 5 + 1 # visibility error I think consistency wins here and self.foo should be able to skip visibility checks too. ---------------------------------------- Bug #9907: Abbreviated method assignment with private attr_writer/attr_reader does not work. https://bugs.ruby-lang.org/issues/9907#change-49844 * Author: Jörg W Mittag * Status: Closed * Priority: Normal * Assignee: * Category: core * Target version: current: 2.2.0 * ruby -v: ruby 2.2.0dev (2014-06-05 trunk 46357) [x86_64-darwin13] * Backport: 2.0.0: REQUIRED, 2.1: DONTNEED ---------------------------------------- This looks like a hole in the specification: ~~~ruby private def foo=(*) end public def foo; 0 end self.foo = 42 self.foo += 42 # private method `foo=' called for main:Object (NoMethodError) private :foo self.foo += 42 # private method `foo' called for main:Object (NoMethodError) ~~~ There is an exception for `private` writers in the rule for private message sends, but apparently that exception needs to broadened so that it also works in the case of abbreviated assignments. I'm not entirely sure what this rule would be, but I don't think it would break backwards compatibility, since all situations that would work differently with the changed rule would currently raise a `NoMethodError` anyway. The rule should be something like: > * `private` methods can only be called without an explicit receiver. > * An exception is made for method assignments, where the literal receiver `self` is also allowed in the assignee method expression. > * This also applies to compound assignments: `self.foo ω= bar` shall *always* succeed if either or both of `foo` and `foo=` are `private`. -- https://bugs.ruby-lang.org/