From: "shugo (Shugo Maeda)" <noreply@ruby-lang.org>
To: ruby-dev@neon.ruby-lang.org
Subject: [ruby-dev:51201] [Ruby master Bug#19132] `**` を引数に指定すると no anonymous keyword rest parameter になる
Date: Thu, 17 Nov 2022 08:52:16 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-100148.20221117085215.82@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-19132.20221116051519.82@ruby-lang.org>
Issue #19132 has been updated by shugo (Shugo Maeda).
shugo (Shugo Maeda) wrote in #note-5:
> nobu (Nobuyoshi Nakada) wrote in #note-4:
> > `:**`に統一でいいのではないでしょうか。
>
> Rubyレベルで公開されている情報が `:**` なので私もそちらに合わせる方がよいように思います。
上記の修正でRBSのテストがこけるのを調べてみたのですが、RubyVM::ASTのテストが通るように以下の修正をしたせいでした。
```
--- a/ast.c
+++ b/ast.c
@@ -348,6 +348,7 @@ static VALUE
var_name(ID id)
{
if (!id) return Qnil;
+ if (!rb_is_local_id(id)) return Qnil;
if (!rb_id2str(id)) return Qnil;
return ID2SYM(id);
}
```
変数名が `**` の時に名前なし扱いするためでしたが、これが `def foo(...)` とかで定義される `*` なども隠してしまっていたようです。
`**` の時だけ隠すという修正もできますが、UnboundMethod#parametersなどでは `**` という変数名が見えているので、RubyVM::ASTも合わせた方がいいように思います。
----------------------------------------
Bug #19132: `**` を引数に指定すると no anonymous keyword rest parameter になる
https://bugs.ruby-lang.org/issues/19132#change-100148
* Author: tommy (Masahiro Tomita)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.2.0preview3 (2022-11-14) [arm64-darwin21]
* Backport: 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED
----------------------------------------
Ruby 3.2.0-preview3 で次のスクリプトを実行するとエラーになります。
```ruby
def hoge(a, *, k: nil, **)
foo(*, **)
end
```
```
% ruby hoge.rb
hoge.rb:2: no anonymous keyword rest parameter
```
次のようにキーワードパラメータが `**` だけであればエラーになりませんでした。
```ruby
def hoge(a, *, **)
foo(*, **)
end
```
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2022-11-17 8:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-16 5:15 [ruby-dev:51196] " tommy (Masahiro Tomita)
2022-11-16 14:16 ` [ruby-dev:51197] " shugo (Shugo Maeda)
2022-11-16 23:03 ` [ruby-dev:51198] " shugo (Shugo Maeda)
2022-11-17 3:23 ` [ruby-dev:51199] " nobu (Nobuyoshi Nakada)
2022-11-17 3:32 ` [ruby-dev:51200] " shugo (Shugo Maeda)
2022-11-17 8:52 ` shugo (Shugo Maeda) [this message]
2022-11-17 9:09 ` [ruby-dev:51202] " yui-knk (Kaneko Yuichiro)
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-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-100148.20221117085215.82@ruby-lang.org \
--to=noreply@ruby-lang.org \
--cc=ruby-dev@neon.ruby-lang.org \
--cc=ruby-dev@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 NNTP newsgroup(s).