Forum: Ruby-dev [ruby-trunk - Feature #8061][Open] 重複するキーワードをエラーにする

Posted by tadf (tadayoshi funaba) (Guest)
on 2013-03-10 01:53
(Received via mailing list)
Issue #8061 has been reported by tadf (tadayoshi funaba).

----------------------------------------
Feature #8061: 重複するキーワードをエラーにする
https://bugs.ruby-lang.org/issues/8061

Author: tadf (tadayoshi funaba)
Status: Open
Priority: Low
Assignee:
Category:
Target version: next minor


重複するキーワードをエラーにする。

def m(a:1, b:2)
  p [a, b]
end

m(a:8, a:9)
Posted by mame (Yusuke Endoh) (Guest)
on 2013-03-10 09:15
(Received via mailing list)
Issue #8061 has been updated by mame (Yusuke Endoh).

Assignee set to matz (Yukihiro Matsumoto)

キーワード引数の実体はハッシュなので、

  { a: 1, a: 2 } #=> { :a => 2 }

がエラーでない以上、これもエラーにならない方が仕様として単純で好きですが、
明らかにミスっぽいケースを検出してあげるのもありですかね。

  m(:a => 8, eval(":a") => 9)
  h = { a: 8 }; m(**h, a: 9)

などはどうするかと合わせて、matz に。

--
Yusuke Endoh <mame@tsg.ne.jp>
----------------------------------------
Feature #8061: 重複するキーワードをエラーにする
https://bugs.ruby-lang.org/issues/8061#change-37449

Author: tadf (tadayoshi funaba)
Status: Open
Priority: Low
Assignee: matz (Yukihiro Matsumoto)
Category:
Target version: next minor


重複するキーワードをエラーにする。

def m(a:1, b:2)
  p [a, b]
end

m(a:8, a:9)
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.