Project

General

Profile

Actions

Bug #15539

closed

Proc.new with no block shouldn't always warn

Added by tenderlovemaking (Aaron Patterson) almost 6 years ago. Updated almost 6 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:91109]

Description

Hi,

r66772 introduced a warning for the following code:

def foo bar = Proc.new
  bar.call
end

foo      { p "block" } # warn
foo ->() { p "block" } # no warn

I don't think this case of Proc.new should warn. To eliminate warnings, I have to rewrite as:

def foo bar = nil
  if bar
    bar.call
  else
    yield
  end
end

Rails uses this "Proc.new" trick here:

I can change Rails, but I want to know why and I don't see any discussion of r66772 (the commit doesn't have a feature number).

Thanks!

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0