From: andrew.kozin@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:69669] [Ruby trunk - Bug #11283] Block assigned implicitly
Date: Thu, 18 Jun 2015 22:45:59 +0000 [thread overview]
Message-ID: <redmine.journal-53030.20150618224558.9ceb9869c12c02d5@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-11283.20150618153632@ruby-lang.org
Issue #11283 has been updated by Andrew Kozin.
I'd expect Ruby to do any of two options:
* Either provide a method with empty proc (`Proc.new`)
* Or call `SyntaxError` as a strict way to ask for the programmer's intention
I think any of these options could follow POLA better than the current one
----------------------------------------
Bug #11283: Block assigned implicitly
https://bugs.ruby-lang.org/issues/11283#change-53030
* Author: Andrew Kozin
* Status: Open
* Priority: Normal
* Assignee:
* ruby -v: 1.9.3, 2.0, 2.1, 2.2, ruby-head
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
That is how it works:
module Test
def self.build(&block)
klass = Class.new(Object)
klass.__send__(:define_method, :foo)
klass.__send__(:define_method, :bar)
klass
end
end
Tested = Test.build { :foo }
# warning: tried to create Proc object without a block
# => Tested
Tested.new.foo
# => :foo
Tested.new.bar
# => :foo
The block is assigned to all calls to `:define_method` via `Object#__send__` implicitly, while it wasn't asked to.
The behaviour is tested under MRI 1.9.3, 2.0, 2.1, 2.2, ruby-head. It doesn't occur under rbx-2 and jruby (1.7, 9.0.0.0).
For the context look at this thread https://github.com/mbj/mutant/issues/356
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2015-06-18 22:23 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-11283.20150618153632@ruby-lang.org>
2015-06-18 15:36 ` [ruby-core:69655] [Ruby trunk - Bug #11283] [Open] Block assigned implicitly andrew.kozin
2015-06-18 15:39 ` [ruby-core:69656] [Ruby trunk - Bug #11283] " andrew.kozin
2015-06-18 15:46 ` [ruby-core:69657] " andrew.kozin
2015-06-18 15:48 ` [ruby-core:69658] " andrew.kozin
2015-06-18 15:49 ` [ruby-core:69659] " andrew.kozin
2015-06-18 15:51 ` [ruby-core:69660] " andrew.kozin
2015-06-18 15:52 ` [ruby-core:69661] " andrew.kozin
2015-06-18 19:11 ` [ruby-core:69664] " funny.falcon
2015-06-18 19:31 ` [ruby-core:69665] " andrew.kozin
2015-06-18 21:56 ` [ruby-core:69667] " 0x0dea+redmine
2015-06-18 22:45 ` andrew.kozin [this message]
2015-06-19 2:25 ` [ruby-core:69673] " 0x0dea+redmine
2015-06-19 5:49 ` [ruby-core:69674] " andrew.kozin
2015-06-30 3:25 ` [ruby-core:69789] " usa
2015-08-14 7:50 ` [ruby-core:70385] " nagachika00
2015-08-17 8:55 ` [ruby-core:70421] " usa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-53030.20150618224558.9ceb9869c12c02d5@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).