Project

General

Profile

Actions

Feature #14603

closed

Better error message when double-splatting hash with string keys

Added by apotonick (Nick Sutterer) about 6 years ago. Updated about 6 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:86113]

Description

I couldn't find an existing issue even though I remember reading about it somewhere.

When double-splatting a hash with string keys, the error message is very cryptic.


a( **{ "key" => 1} )
#=> TypeError (wrong argument type String (expected Symbol))

Would it make sense to have a more descriptive error message here, such as "hash key "key" is not a Symbol" or something?

Updated by shevegen (Robert A. Heiler) about 6 years ago

Ideally we could have some means to control the warning/error format. That
way people could select which variant to prefer, the default one or any
other way, like the one shown above.

Actions #2

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r62752.


vm.c: refined error message

  • vm.c (kw_check_symbol): refined the error message for non-symbol
    key. [Feature #14603]
Actions

Also available in: Atom PDF

Like0
Like0Like0