Skip to content

params can't be used as keyword arguments #1592

Open
@baelter

Description

@baelter

We can't pass params hash and expect keyword args to be matched because of the current IndifferentHash implementation.

def a(a:, **); end
a(Hash[a: 1]) # => nil
a(Sinatra::IndifferentHash[a: 1]) # => ArgumentError (wrong number of arguments (given 1, expected 0; required keyword: a))
a(**Sinatra::IndifferentHash[a: 1]) # => TypeError (hash key "a" is not a Symbol)

Changing the IndifferentHash private method convert_key to always return key.to_s.to_sym solves this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions