ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: mame@ruby-lang.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:95634] [Ruby master Feature#16289] Reduce duplicated warnings for the change of Ruby 3 keyword arguments
Date: Fri, 01 Nov 2019 13:26:02 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-82421.20191101132602.b84deb7cbe99587b@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-16289.20191101032931@ruby-lang.org

Issue #16289 has been updated by mame (Yusuke Endoh).


> It leads a memory leak.

Theoretically, yes.  Even if iseqs of caller or callee are free'd, the corresponding records are not free'd.  But honestly I don't think it is worth elaborating the feature for some reasons:

(1) in practice, the case would be rare (to cause the leak, we need to repeatedly create iseq by using "eval" and trigger a warning in the iseq);
(2) the leak does not occur if a waring is not emitted (and it should be fixed); and
(3) this hack is only for Ruby 2.7.

Before implementing the patch, I discussed with ko1.  At first I was going to avoid the leak by adding some fields to iseq, but he objected the approach and recommended the above design.  Now I agree with him.


> And different warnings won't be suppressed too?

It was not intended, but it would be also very rare to trigger different keyword warnings in one call, I guess.

----------------------------------------
Feature #16289: Reduce duplicated warnings for the change of Ruby 3 keyword arguments
https://bugs.ruby-lang.org/issues/16289#change-82421

* Author: mame (Yusuke Endoh)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
## Problem

Currently, the interpreter emits 200 lines of warnings against the following program.

```ruby
def foo(**opt); end
100.times { foo({kw:1}) }
```

```
$ ./miniruby -e 'def foo(**opt); end; 100.times { foo({kw:1}) }'
-e:1: warning: The last argument is used as the keyword parameter
-e:1: warning: for `foo' defined here
-e:1: warning: The last argument is used as the keyword parameter
-e:1: warning: for `foo' defined here
-e:1: warning: The last argument is used as the keyword parameter
-e:1: warning: for `foo' defined here
...
```

In theory, the warnings are not harmful because they don't stop or interfere the execution.  But in practice, I'm afraid if they are annoying because they flush all console logs away.
I think that the warning is not needed if the call is already warned.


## Proposal

How about limiting the count of warnings to at most once for each pair of caller and callee?

I've created [a pull request](https://github.com/ruby/ruby/pull/2458).  It records all pairs of caller position and callee iseq when emitting a warning, and suppress the warning if the same pair of caller and callee is already warned.

What do you think?



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

  parent reply	other threads:[~2019-11-01 13:26 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-16289.20191101032931@ruby-lang.org>
2019-11-01  3:29 ` [ruby-core:95627] [Ruby master Feature#16289] Reduce duplicated warnings for the change of Ruby 3 keyword arguments mame
2019-11-01  4:43   ` [ruby-core:95630] " Eric Wong
2019-11-01  4:38 ` [ruby-core:95629] " ruby-core
2019-11-01  7:03 ` [ruby-core:95631] " nobu
2019-11-01 13:26 ` mame [this message]
2019-11-02  8:00 ` [ruby-core:95651] " mame
2019-11-02 12:56 ` [ruby-core:95653] " eregontp
2019-11-02 15:47 ` [ruby-core:95655] " ruby-core
2019-11-04 16:41 ` [ruby-core:95670] " daniel
2019-11-05  9:35 ` [ruby-core:95692] " shevegen
2019-11-10 11:24 ` [ruby-core:95775] " eregontp
2019-11-10 22:20 ` [ruby-core:95780] " sam.saffron
2019-11-11  1:00 ` [ruby-core:95783] " sam.saffron
2019-11-29  8:12 ` [ruby-core:96025] " mame
2019-12-23  7:37 ` [ruby-core:96418] " ruby-core
2019-12-23 11:49 ` [ruby-core:96425] " mame
2019-12-23 12:51 ` [ruby-core:96427] " eregontp
2019-12-23 17:47 ` [ruby-core:96439] " merch-redmine
2019-12-23 21:49 ` [ruby-core:96441] " ruby-core
2019-12-24  7:06 ` [ruby-core:96452] " mame
2019-12-24  7:10 ` [ruby-core:96453] " matz
2019-12-24  7:23 ` [ruby-core:96455] " mame
2019-12-24  7:34 ` [ruby-core:96456] " mame

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-82421.20191101132602.b84deb7cbe99587b@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).