Em 07-11-2012 11:00, Aaron Patterson escreveu:
> On Wed, Nov 07, 2012 at 01:06:34PM +0900, marcandre (Marc-Andre Lafortune) wrote:
>> Issue #7299 has been reported by marcandre (Marc-Andre Lafortune).
>>
>> ----------------------------------------
>> Feature #7299: Ruby should not completely ignore blocks.
>> https://bugs.ruby-lang.org/issues/7299
>>
>> Author: marcandre (Marc-Andre Lafortune)
>> Status: Open
>> Priority: Normal
>> Assignee:
>> Category: core
>> Target version:
>>
>>
>> Ruby should not completely ignore blocks.
>>
>>    const_set :Example, Class.new do
>>      p "Hello, world"
>>    end
>>    # Doesn't print anything, generate any warning nor error.
>>
>> To minimize any impact, Ruby should issue a warning, and in future version could even raise an error.
>>
>> Even unused variables provide warnings in verbose mode, and they have their use.
>>
>> I can't think of a case where passing a block to a builtin method that doesn't accept a block is not a programming error though.
> This happens with normal ruby code:
>
>    ruby -w -e'def foo; 10; end; p foo { raise };'
>
> Why would "builtin" methods be special?

I agree. I'd prefer to just raise an exception when a block is passed 
and no block_given? or yield is called for the method.

I was bitten some times by bugs hard to detect because of this behavior 
where I thought the block was being given to a method while it was being 
given to another one that didn't even expect any block.