ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: mail@stefanschuessler.de
To: ruby-core@ruby-lang.org
Subject: [ruby-core:91563] [Ruby trunk Feature#15574] Prohibit to pass a block on super() implicitly
Date: Fri, 15 Feb 2019 11:02:35 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-76826.20190215110233.d840cbc9dd4f23bc@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15574.20190130071217@ruby-lang.org

Issue #15574 has been updated by sos4nt (Stefan Schüßler).


sawa (Tsuyoshi Sawada) wrote:
> In such case, i.e., when you don't want to take the responsibility of managing the arguments and blocks, I think you should use `super`, not `super(foo, &block)`

Calling `super` (without parentheses) would pass two arguments (`foo` and `bar`) to the super method which only takes one argument, resulting in an `ArgumentError`.

----------------------------------------
Feature #15574: Prohibit to pass a block on super() implicitly
https://bugs.ruby-lang.org/issues/15574#change-76826

* Author: ko1 (Koichi Sasada)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
----------------------------------------
As described in [Feature #15554], `super()` (not `super`) pass the given block.

```
class C
  def foo
    p block_given?
  end
end

class C1 < C
  def foo
    super   #=> true
    super() #=> true
  end
end

C1.new.foo{}
```

`super` (without parameters) passes all passed parameters so it is no surprise to pass given block. 

However, `super()` (with parameters. In this case, it passes 0 parameters) also pass given block implicitly.

I'm not sure who use this behavior, but I think it is simple to prohibit such implicit block passing.




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

  parent reply	other threads:[~2019-02-15 11:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-15574.20190130071217@ruby-lang.org>
2019-01-30  7:12 ` [ruby-core:91332] [Ruby trunk Feature#15574] Prohibit to pass a block on super() implicitly ko1
2019-01-30 10:12 ` [ruby-core:91335] " Webhostingonedollar102
2019-01-30 10:17 ` [ruby-core:91336] " Webhostingonedollar102
2019-01-30 12:12 ` [ruby-core:91338] " eregontp
2019-02-04 18:25 ` [ruby-core:91394] " ruby-core
2019-02-05  2:02 ` [ruby-core:91402] " ko1
2019-02-05  3:27 ` [ruby-core:91403] " duerst
2019-02-05  4:42 ` [ruby-core:91404] " sawadatsuyoshi
2019-02-15 10:20 ` [ruby-core:91558] " mail
2019-02-15 10:48 ` [ruby-core:91562] " sawadatsuyoshi
2019-02-15 11:02 ` mail [this message]
2019-02-15 11:10 ` [ruby-core:91564] " sawadatsuyoshi
2019-02-15 11:42 ` [ruby-core:91566] " eregontp
2019-02-15 11:46 ` [ruby-core:91567] " mail
2019-10-21  8:14 ` [ruby-core:95451] [Ruby master " ko1

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-76826.20190215110233.d840cbc9dd4f23bc@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).