Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double splat in method definition prevents declaring local variables with a type. #5693

Closed
da99 opened this issue Feb 8, 2018 · 0 comments
Closed

Comments

@da99
Copy link

da99 commented Feb 8, 2018

Declaring local variables with a type seems to be a new feature, which might explain this odd behaviour below. It appears when a double splat is used in the method and the same Symbol for a key (e.g. place) is used for a local variable with a declared type:

def show(**attrs)
  place : String = "w" # Not recommended practice at the moment.
  puts place
end

show(name: "Bobby")  # This works.

show(name: "Bobby", place: "World") # This fails:
#
#in tmp.cr:2: variable 'place' already declared
#
#  place : String = "w"
#  ^~~~~

(Originally posted on stackoverflow)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants