* [ruby-core:69655] [Ruby trunk - Bug #11283] [Open] Block assigned implicitly
[not found] <redmine.issue-11283.20150618153632@ruby-lang.org>
@ 2015-06-18 15:36 ` andrew.kozin
2015-06-18 15:39 ` [ruby-core:69656] [Ruby trunk - Bug #11283] " andrew.kozin
` (14 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: andrew.kozin @ 2015-06-18 15:36 UTC (permalink / raw)
To: ruby-core
Issue #11283 has been reported by Andrew Kozin.
----------------------------------------
Bug #11283: Block assigned implicitly
https://bugs.ruby-lang.org/issues/11283
* 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 methods implicitly, while it wasn't asked to.
The interpreter sends warning message, but doesn't raise `SyntaxError` as it IMHO should be.
The behaviour is tested under MRI 1.9.3, 2.0, 2.1, 2.2, ruby-head. Exceptions are raised by Rbx and Jruby interpreters.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:69656] [Ruby trunk - Bug #11283] Block assigned implicitly
[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 ` andrew.kozin
2015-06-18 15:46 ` [ruby-core:69657] " andrew.kozin
` (13 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: andrew.kozin @ 2015-06-18 15:39 UTC (permalink / raw)
To: ruby-core
Issue #11283 has been updated by Andrew Kozin.
Description updated
----------------------------------------
Bug #11283: Block assigned implicitly
https://bugs.ruby-lang.org/issues/11283#change-53016
* 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 methods implicitly, while it wasn't asked to.
The interpreter sends warning message, but doesn't raise `SyntaxError` as it IMHO should be.
The behaviour is tested under MRI 1.9.3, 2.0, 2.1, 2.2, ruby-head. Exceptions are raised by Rbx and Jruby interpreters.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:69657] [Ruby trunk - Bug #11283] Block assigned implicitly
[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 ` andrew.kozin
2015-06-18 15:48 ` [ruby-core:69658] " andrew.kozin
` (12 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: andrew.kozin @ 2015-06-18 15:46 UTC (permalink / raw)
To: ruby-core
Issue #11283 has been updated by Andrew Kozin.
Description updated
----------------------------------------
Bug #11283: Block assigned implicitly
https://bugs.ruby-lang.org/issues/11283#change-53017
* 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 methods implicitly, while it wasn't asked to.
The behaviour is tested under MRI 1.9.3, 2.0, 2.1, 2.2, ruby-head. Exceptions are raised by Rbx and Jruby interpreters.
For the context look at this thread https://github.com/mbj/mutant/issues/356
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:69658] [Ruby trunk - Bug #11283] Block assigned implicitly
[not found] <redmine.issue-11283.20150618153632@ruby-lang.org>
` (2 preceding siblings ...)
2015-06-18 15:46 ` [ruby-core:69657] " andrew.kozin
@ 2015-06-18 15:48 ` andrew.kozin
2015-06-18 15:49 ` [ruby-core:69659] " andrew.kozin
` (11 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: andrew.kozin @ 2015-06-18 15:48 UTC (permalink / raw)
To: ruby-core
Issue #11283 has been updated by Andrew Kozin.
Description updated
----------------------------------------
Bug #11283: Block assigned implicitly
https://bugs.ruby-lang.org/issues/11283#change-53018
* 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 invocations of `__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. Exceptions are raised by Rbx and Jruby interpreters.
For the context look at this thread https://github.com/mbj/mutant/issues/356
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:69659] [Ruby trunk - Bug #11283] Block assigned implicitly
[not found] <redmine.issue-11283.20150618153632@ruby-lang.org>
` (3 preceding siblings ...)
2015-06-18 15:48 ` [ruby-core:69658] " andrew.kozin
@ 2015-06-18 15:49 ` andrew.kozin
2015-06-18 15:51 ` [ruby-core:69660] " andrew.kozin
` (10 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: andrew.kozin @ 2015-06-18 15:49 UTC (permalink / raw)
To: ruby-core
Issue #11283 has been updated by Andrew Kozin.
Description updated
----------------------------------------
Bug #11283: Block assigned implicitly
https://bugs.ruby-lang.org/issues/11283#change-53019
* 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 on 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. Exceptions are raised by Rbx and Jruby interpreters.
For the context look at this thread https://github.com/mbj/mutant/issues/356
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:69660] [Ruby trunk - Bug #11283] Block assigned implicitly
[not found] <redmine.issue-11283.20150618153632@ruby-lang.org>
` (4 preceding siblings ...)
2015-06-18 15:49 ` [ruby-core:69659] " andrew.kozin
@ 2015-06-18 15:51 ` andrew.kozin
2015-06-18 15:52 ` [ruby-core:69661] " andrew.kozin
` (9 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: andrew.kozin @ 2015-06-18 15:51 UTC (permalink / raw)
To: ruby-core
Issue #11283 has been updated by Andrew Kozin.
Description updated
----------------------------------------
Bug #11283: Block assigned implicitly
https://bugs.ruby-lang.org/issues/11283#change-53020
* 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 on 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/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:69661] [Ruby trunk - Bug #11283] Block assigned implicitly
[not found] <redmine.issue-11283.20150618153632@ruby-lang.org>
` (5 preceding siblings ...)
2015-06-18 15:51 ` [ruby-core:69660] " andrew.kozin
@ 2015-06-18 15:52 ` andrew.kozin
2015-06-18 19:11 ` [ruby-core:69664] " funny.falcon
` (8 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: andrew.kozin @ 2015-06-18 15:52 UTC (permalink / raw)
To: ruby-core
Issue #11283 has been updated by Andrew Kozin.
Description updated
----------------------------------------
Bug #11283: Block assigned implicitly
https://bugs.ruby-lang.org/issues/11283#change-53021
* 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/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:69664] [Ruby trunk - Bug #11283] Block assigned implicitly
[not found] <redmine.issue-11283.20150618153632@ruby-lang.org>
` (6 preceding siblings ...)
2015-06-18 15:52 ` [ruby-core:69661] " andrew.kozin
@ 2015-06-18 19:11 ` funny.falcon
2015-06-18 19:31 ` [ruby-core:69665] " andrew.kozin
` (7 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: funny.falcon @ 2015-06-18 19:11 UTC (permalink / raw)
To: ruby-core
Issue #11283 has been updated by Yura Sokolov.
This is "hidden feature", not the bug: `Proc.new` can consume unnamed block passed to method.
It makes possible following code:
````ruby
def do_now_or_later
if can_do_now?
yield
else
do_it_later Proc.new
end
end
do_now_or_later { puts 'hi' }
````
In your case block is passed to implicit `Proc.new` in the implementation of `define_method`.
I agree, that it is a bit weird feature.
----------------------------------------
Bug #11283: Block assigned implicitly
https://bugs.ruby-lang.org/issues/11283#change-53025
* 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/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:69665] [Ruby trunk - Bug #11283] Block assigned implicitly
[not found] <redmine.issue-11283.20150618153632@ruby-lang.org>
` (7 preceding siblings ...)
2015-06-18 19:11 ` [ruby-core:69664] " funny.falcon
@ 2015-06-18 19:31 ` andrew.kozin
2015-06-18 21:56 ` [ruby-core:69667] " 0x0dea+redmine
` (6 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: andrew.kozin @ 2015-06-18 19:31 UTC (permalink / raw)
To: ruby-core
Issue #11283 has been updated by Andrew Kozin.
This feature buzzes and wiggles aerials like a bug.
I cannot see why is it needed for your example. It is pretty explicit and has no hidden calls. Both the `yield` and `Proc.new` are used intentionally, while in my examples they weren't.
----------------------------------------
Bug #11283: Block assigned implicitly
https://bugs.ruby-lang.org/issues/11283#change-53026
* 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/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:69667] [Ruby trunk - Bug #11283] Block assigned implicitly
[not found] <redmine.issue-11283.20150618153632@ruby-lang.org>
` (8 preceding siblings ...)
2015-06-18 19:31 ` [ruby-core:69665] " andrew.kozin
@ 2015-06-18 21:56 ` 0x0dea+redmine
2015-06-18 22:45 ` [ruby-core:69669] " andrew.kozin
` (5 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: 0x0dea+redmine @ 2015-06-18 21:56 UTC (permalink / raw)
To: ruby-core
Issue #11283 has been updated by D.E. Akers.
Andrew, what would you like Ruby to do when you attempt to define a method with no body?
----------------------------------------
Bug #11283: Block assigned implicitly
https://bugs.ruby-lang.org/issues/11283#change-53027
* 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/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:69669] [Ruby trunk - Bug #11283] Block assigned implicitly
[not found] <redmine.issue-11283.20150618153632@ruby-lang.org>
` (9 preceding siblings ...)
2015-06-18 21:56 ` [ruby-core:69667] " 0x0dea+redmine
@ 2015-06-18 22:45 ` andrew.kozin
2015-06-19 2:25 ` [ruby-core:69673] " 0x0dea+redmine
` (4 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: andrew.kozin @ 2015-06-18 22:45 UTC (permalink / raw)
To: ruby-core
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/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:69673] [Ruby trunk - Bug #11283] Block assigned implicitly
[not found] <redmine.issue-11283.20150618153632@ruby-lang.org>
` (10 preceding siblings ...)
2015-06-18 22:45 ` [ruby-core:69669] " andrew.kozin
@ 2015-06-19 2:25 ` 0x0dea+redmine
2015-06-19 5:49 ` [ruby-core:69674] " andrew.kozin
` (3 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: 0x0dea+redmine @ 2015-06-19 2:25 UTC (permalink / raw)
To: ruby-core
Issue #11283 has been updated by D.E. Akers.
> * Either provide a method with empty proc (`Proc.new`)
That is, in fact, exactly what Ruby is doing:
```ruby
def build
Class.new { define_method :foo, Proc.new }
end
build{ :bar }.new.foo # => :bar
```
`Proc.new`, called without an explicit block, will instead attempt to use the one that was passed to the surrounding method:
```ruby
def foo
Proc.new.call 1
end
foo { |x| x + 1 } # => 2
```
Note well that methods need not explicitly declare that they take a block. This double whammy of implicit behavior is certainly "astonishing" the first time you encounter it, but it all hangs together in the final analysis.
> * Or call `SyntaxError` as a strict way to ask for the programmer's intention
This is a semantic rather than syntactic concern, and Ruby does warn against it. That it doesn't raise an `ArgumentError` as it does for standalone `Proc.new` is indeed unexpected, and may well be a bug.
----------------------------------------
Bug #11283: Block assigned implicitly
https://bugs.ruby-lang.org/issues/11283#change-53033
* 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/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:69674] [Ruby trunk - Bug #11283] Block assigned implicitly
[not found] <redmine.issue-11283.20150618153632@ruby-lang.org>
` (11 preceding siblings ...)
2015-06-19 2:25 ` [ruby-core:69673] " 0x0dea+redmine
@ 2015-06-19 5:49 ` andrew.kozin
2015-06-30 3:25 ` [ruby-core:69789] " usa
` (2 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: andrew.kozin @ 2015-06-19 5:49 UTC (permalink / raw)
To: ruby-core
Issue #11283 has been updated by Andrew Kozin.
Not, in my examples (from the initial post) it does not do that, but something different. Namely, it doesn't assigning a **new** proc (that would be OK)
Instead, the interpreter it looks around in search **what else** it could use when I doesn't send a proc, then takes what it found somewhere and pushes it to the method.
MRI doesn't let me decide whether the method should be called without a proc (that should be interpreted as asking for `Proc.new`, as in your example).
**This** is the bug, not the way it works out the `:define_method` call.
----------------------------------------
Bug #11283: Block assigned implicitly
https://bugs.ruby-lang.org/issues/11283#change-53034
* 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/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:69789] [Ruby trunk - Bug #11283] Block assigned implicitly
[not found] <redmine.issue-11283.20150618153632@ruby-lang.org>
` (12 preceding siblings ...)
2015-06-19 5:49 ` [ruby-core:69674] " andrew.kozin
@ 2015-06-30 3:25 ` usa
2015-08-14 7:50 ` [ruby-core:70385] " nagachika00
2015-08-17 8:55 ` [ruby-core:70421] " usa
15 siblings, 0 replies; 16+ messages in thread
From: usa @ 2015-06-30 3:25 UTC (permalink / raw)
To: ruby-core
Issue #11283 has been updated by Usaku NAKAMURA.
Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: WONTFIX, 2.1: REQUIRED, 2.2: REQUIRED
----------------------------------------
Bug #11283: Block assigned implicitly
https://bugs.ruby-lang.org/issues/11283#change-53170
* Author: Andrew Kozin
* Status: Closed
* Priority: Normal
* Assignee:
* ruby -v: 1.9.3, 2.0, 2.1, 2.2, ruby-head
* Backport: 2.0.0: WONTFIX, 2.1: REQUIRED, 2.2: REQUIRED
----------------------------------------
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/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:70385] [Ruby trunk - Bug #11283] Block assigned implicitly
[not found] <redmine.issue-11283.20150618153632@ruby-lang.org>
` (13 preceding siblings ...)
2015-06-30 3:25 ` [ruby-core:69789] " usa
@ 2015-08-14 7:50 ` nagachika00
2015-08-17 8:55 ` [ruby-core:70421] " usa
15 siblings, 0 replies; 16+ messages in thread
From: nagachika00 @ 2015-08-14 7:50 UTC (permalink / raw)
To: ruby-core
Issue #11283 has been updated by Tomoyuki Chikanaga.
Backport changed from 2.0.0: WONTFIX, 2.1: REQUIRED, 2.2: REQUIRED to 2.0.0: WONTFIX, 2.1: REQUIRED, 2.2: WONTFIX
The change of define_method's behavior is added into NEWS file at r50971. I think this is a spec change even thought original behavior is confusing.
----------------------------------------
Bug #11283: Block assigned implicitly
https://bugs.ruby-lang.org/issues/11283#change-53788
* Author: Andrew Kozin
* Status: Closed
* Priority: Normal
* Assignee:
* ruby -v: 1.9.3, 2.0, 2.1, 2.2, ruby-head
* Backport: 2.0.0: WONTFIX, 2.1: REQUIRED, 2.2: WONTFIX
----------------------------------------
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/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [ruby-core:70421] [Ruby trunk - Bug #11283] Block assigned implicitly
[not found] <redmine.issue-11283.20150618153632@ruby-lang.org>
` (14 preceding siblings ...)
2015-08-14 7:50 ` [ruby-core:70385] " nagachika00
@ 2015-08-17 8:55 ` usa
15 siblings, 0 replies; 16+ messages in thread
From: usa @ 2015-08-17 8:55 UTC (permalink / raw)
To: ruby-core
Issue #11283 has been updated by Usaku NAKAMURA.
Backport changed from 2.0.0: WONTFIX, 2.1: REQUIRED, 2.2: WONTFIX to 2.0.0: WONTFIX, 2.1: WONTFIX, 2.2: WONTFIX
I agree with you, chikanaga-san.
----------------------------------------
Bug #11283: Block assigned implicitly
https://bugs.ruby-lang.org/issues/11283#change-53830
* Author: Andrew Kozin
* Status: Closed
* Priority: Normal
* Assignee:
* ruby -v: 1.9.3, 2.0, 2.1, 2.2, ruby-head
* Backport: 2.0.0: WONTFIX, 2.1: WONTFIX, 2.2: WONTFIX
----------------------------------------
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/
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2015-08-17 8:20 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[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 ` [ruby-core:69669] " andrew.kozin
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
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).