From: mame@... Date: 2019-12-23T11:49:49+00:00 Subject: [ruby-core:96425] [Ruby master Feature#16289] Reduce duplicated warnings for the change of Ruby 3 keyword arguments Issue #16289 has been updated by mame (Yusuke Endoh). Assignee set to mame (Yusuke Endoh) Status changed from Closed to Assigned @marcandre , thank you for creating a pull request. Your proposal: old: The last argument is used as keyword parameters; maybe ** should be added to the call new Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call old: The keyword argument is passed as the last hash parameter new: Passing the keyword argument as the last hash parameter is deprecated old: The last argument is split into positional and keyword parameters new: Splitting the last argument into positional and keyword parameters is deprecated I think they are better. I'm okay to merge your patch, if we can merge it before 2.7.0 release. (But I'm against changing them after the release, i.e., 2.7.1 or later.) @matz @jeremyevans0 @eregon What do you think? @naruse If matz accepted, can we merge it? ---------------------------------------- Feature #16289: Reduce duplicated warnings for the change of Ruby 3 keyword arguments https://bugs.ruby-lang.org/issues/16289#change-83347 * Author: mame (Yusuke Endoh) * Status: Assigned * Priority: Normal * Assignee: mame (Yusuke Endoh) * 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/ Unsubscribe: