Project

General

Profile

Bug #16406

`(lambda_proc << normal_proc).lambda?` should return false

Added by alanwu (Alan Wu) 8 months ago. Updated 5 months ago.

Status:
Closed
Priority:
Normal
Target version:
ruby -v:
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]
[ruby-core:96139]
Tags:

Description

Consider:

plus = proc { |a, b| a + b }
mult_two = ->(x) { x * 2 }
composed = mult_two << plus
p [composed. lambda?, composed.call([1, 2])]

I think this ought to print [false, 6] instead of [true, 6], as the call composed.call([1, 2]) is clearly not using lambda semantics.
Since composed = f << g calls g first, I think it makes sense to report #lambda? base on whether g has lambda semantics.
I have a pull request at https://github.com/ruby/ruby/pull/2729 to make this change.

#1

Updated by alanwu (Alan Wu) 8 months ago

  • Subject changed from `(lambda_proc << normal_proc).lambda?` returns true to `(lambda_proc << normal_proc).lambda?` should return false

Updated by ko1 (Koichi Sasada) 8 months ago

It was discussed and Matz approved to fix it after Ruby 2.7 release.

#3

Updated by nobu (Nobuyoshi Nakada) 8 months ago

  • Target version set to 2.8
#4

Updated by nobu (Nobuyoshi Nakada) 8 months ago

  • Backport changed from 2.5: UNKNOWN, 2.6: UNKNOWN to 2.5: DONTNEED, 2.6: REQUIRED, 2.7: REQUIRED
#5

Updated by alanwu (Alan Wu) 8 months ago

  • Description updated (diff)

Updated by nobu (Nobuyoshi Nakada) 8 months ago

  • Assignee set to alanwu (Alan Wu)
  • Status changed from Open to Assigned
#8

Updated by alanwu (Alan Wu) 8 months ago

  • Status changed from Assigned to Closed

Applied in changeset git|3264a00958f56e1ba75a95c93e59fc9cccf323e8.


Fix Proc#<< spec

[Bug #16406]

Updated by naruse (Yui NARUSE) 5 months ago

  • Backport changed from 2.5: DONTNEED, 2.6: REQUIRED, 2.7: REQUIRED to 2.5: DONTNEED, 2.6: REQUIRED, 2.7: DONE

ruby_2_7 52bb32d6b71365cb24273de3eed5a712206815f3 [Backport #16406].

Also available in: Atom PDF