From: merch-redmine@... Date: 2020-01-11T23:59:46+00:00 Subject: [ruby-core:96796] [Ruby master Bug#16500] Argument added both to splat and last &block argument Issue #16500 has been updated by jeremyevans0 (Jeremy Evans). ioquatix (Samuel Williams) wrote: > On Ruby 2.7.0: > > ``` > irb(main):020:-> x = [1, 2, ->{}]; puts(*x, &x.pop) > 1 > 2 > => nil > irb(main):021:-> x = [1, 2, ->{}]; puts(*x, &x.last) > 1 > 2 > #<Proc:0x0000562763a56398 (irb):21 (lambda)> > => nil > ``` > > This seems like buggy behaviour related to the original issue. I'm not sure if that behavior is buggy. puts ignores a passed block, so the behavior seems expected. ```ruby def a(*args, &b) p [args, b] end x = [1, 2, ->{}]; a(*x, &x.pop) # => [[1, 2], #<Proc:0x00001100c1362518 (irb):4 (lambda)>] x = [1, 2, ->{}]; a(*x, &x.last) # => [[1, 2, #<Proc:0x000011004f2b0ba0 (irb):5 (lambda)>], #<Proc:0x000011004f2b0ba0 (irb):5 (lambda)>] ``` Same results with Ruby 1.9. ---------------------------------------- Bug #16500: Argument added both to splat and last &block argument https://bugs.ruby-lang.org/issues/16500#change-83789 * Author: anatolik (Anatol Pomozov) * Status: Open * Priority: Normal * Assignee: ioquatix (Samuel Williams) * Target version: * ruby -v: 2.7.0 * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- Here is a followup for a ruby2.7 issue discussed here https://gitlab.com/groups/gitlab-org/-/epics/2380 I run gitlab with ruby2.7. Things work mostly fine except one weird issue. gitlab/lib/api/api_guard.rb calls Rack's `use` method: ```ruby use Rack::OAuth2::Server::Resource::Bearer, 'The API' do |request| # The authenticator only fetches the raw token string # Must yield access token to store it in the env request.access_token end ``` The `use` method looks like ```ruby def use(middleware, *args, &block) if @map mapping, @map = @map, nil @use << proc { |app| generate_map app, mapping } end @use << proc { |app| middleware.new(app, *args, &block) } end ``` For some reason `Proc` method set to `&block` *and* added to `args`. It sounds wrong. `Proc` should be set to `&block` only and `args` should contain only 1 argument. -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>