Project

General

Profile

Actions

Feature #16289

closed

Reduce duplicated warnings for the change of Ruby 3 keyword arguments

Added by mame (Yusuke Endoh) about 5 years ago. Updated almost 5 years ago.

Status:
Closed
Target version:
-
[ruby-core:95627]

Description

Problem

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

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. 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?


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #16345: Don't emit deprecation warnings by default.ClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0