rbs
rbs copied to clipboard
Disallow duplicate argument names
Currently RBS allows duplicate argument names.
# In RBS, all of the following are valid
class C
def required_positional: (String x, String x) -> void
def required_keyword: (x: String, x: String) -> void
def positional_keyword: (String x, x: String) -> void
end
It conceals mistakes, like https://github.com/ruby/gem_rbs_collection/pull/50.
I'm 100% sure that RBS should reject duplicate keyword argument names. Kwargs are represented as a Hash, which uses argument names as hash keys, so duplicated kwarg names are completely meaningless. But RBS can distinguish duplicate names in other cases, and it will introduce language change if we fix the problem. So I'm not 100% sure, but it will be useful if RBS reject duplicate argument names for all cases.