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

Do not allow non-hash values in HashOf contract #190

Merged
merged 1 commit into from
Jul 25, 2015

Conversation

abevoelker
Copy link
Contributor

Given these HashOf contracts:

Contract HashOf[Symbol => String] => Any
def foo(args)
end

Contract KeywordArgs[:hash => HashOf[Symbol => String]] => Any
def bar(args)
end

calling foo(nil) or bar(hash: nil) results in NoMethodError: undefined method``keys' for nil:NilClass

@abevoelker abevoelker force-pushed the do-not-allow-nil-hashof branch from 35faf33 to 539d758 Compare July 25, 2015 04:57
@abevoelker abevoelker changed the title Do not allow nil values for HashOf contract Do not allow non-hash values in HashOf contract Jul 25, 2015
@abevoelker
Copy link
Contributor Author

Actually I amended the commit since it wasn't really a thorough fix - you could pass in pretty much anything that isn't a Hash to trigger the error, such as foo(1). I don't know if is_a?(Hash) is too strict of a check or whatnot so let me know if there is a better way to do it.

@waterlink
Copy link
Collaborator

LGTM

waterlink added a commit that referenced this pull request Jul 25, 2015
Do not allow non-hash values in HashOf contract
@waterlink waterlink merged commit 8b68139 into egonSchiele:master Jul 25, 2015
@waterlink
Copy link
Collaborator

@abevoelker Good catch! Thanks!

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

Successfully merging this pull request may close these issues.

2 participants