Project

General

Profile

Bug #15672

Lambda implicit arguments, differences between lambda {} and -> {} specifications

Added by takeshinoda (Takeshi Shinoda) 3 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.0dev (2019-03-18 trunk 67291) [x86_64-darwin18]
[ruby-core:91859]

Description

Hi

Are the following differences intentional?

$ ruby -v
ruby 2.7.0dev (2019-03-18 trunk 67291) [x86_64-darwin18]
$ cat ptn1.rb
a = -> { p @1 }
a.call(1)
 $ ruby ptn1.rb
Traceback (most recent call last):
        1: from ptn1.rb:2:in `<main>'
ptn1.rb:1:in `block in <main>': wrong number of arguments (given 1, expected 0) (ArgumentError)
$ cat ptn2.rb
a = lambda { p @1 }
a.call(1)
 $ ruby ptn2.rb
1

thanks

Associated revisions

Revision 964bbc16
Added by nobu (Nobuyoshi Nakada) 3 months ago

parse.y: numbered parameter in lambda

  • parse.y (lambda): support numbered parameters, only when no argument list including empty parentheses, like empty vertical bars. [ruby-core:91859] [Bug #15672]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 67295
Added by nobu (Nobuyoshi Nakada) 3 months ago

parse.y: numbered parameter in lambda

  • parse.y (lambda): support numbered parameters, only when no argument list including empty parentheses, like empty vertical bars. [ruby-core:91859] [Bug #15672]

History

Updated by shevegen (Robert A. Heiler) 3 months ago

Koichi said it will be fixed. :)

(I guess this was never intentional, thus a bug.)

#3

Updated by nobu (Nobuyoshi Nakada) 3 months ago

  • Status changed from Open to Closed

Applied in changeset trunk|r67295.


parse.y: numbered parameter in lambda

  • parse.y (lambda): support numbered parameters, only when no argument list including empty parentheses, like empty vertical bars. [ruby-core:91859] [Bug #15672]
#4

Updated by nobu (Nobuyoshi Nakada) 3 months ago

Hanmac (Hans Mackowiak) wrote:

Duplicate of #15620

It is irrelevant.

Also available in: Atom PDF