Issue #7299 has been updated by marcandre (Marc-Andre Lafortune).


matz (Yukihiro Matsumoto) wrote:
> So you think of changing introducing new functions. I see.
> In that case, it's better to submit a new issue for the idea, with API proposal.

Of course, but first I wanted to validate you were positive with the idea of warning for unused block

tenderlove wrote:
>  This happens with normal ruby code:
>  Why would "builtin" methods be special?

Agreed, it would be best if user methods also warned. I was just lacking ambition by suggesting it only for builtin methods :-)

Rodrigo's suggestion of flagging `block_given?`, `yield`, (as well as Proc.new, super and &capture_block) would work.
----------------------------------------
Feature #7299: Ruby should not completely ignore blocks.
https://bugs.ruby-lang.org/issues/7299#change-32568

Author: marcandre (Marc-Andre Lafortune)
Status: Rejected
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.

If this is approved, I volunteer to implement this.



-- 
http://bugs.ruby-lang.org/