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

Implement tuple and named tuple covariance #2576

Merged
merged 2 commits into from
May 10, 2016
Merged

Conversation

asterite
Copy link
Member

@asterite asterite commented May 10, 2016

Fixes #357

This also creates tuples/named-tuples of unions instead of unions of tuples/named-tuples, if the size/keys match. So this is possible:

#1.
ary = [] of {Int32 | String, Char}
ary << {1, 'a'}
ary << {"hello", 'a'}

#2.
class Foo; end
class Bar < Foo; end

ary = [] of {Foo, Foo}
ary << {Foo.new, Bar.new}

And:

#1.
ary = [] of {foo: Int32 | String, bar: Char}
ary << {foo: 1, bar: 'a'}
ary << {bar: 'a', foo: "hello"}

#2.
class Foo; end
class Bar < Foo; end

ary = [] of {foo: Foo, bar: Foo}
ary << {foo: Foo.new, bar: Bar.new}

The snippets above don't work right now, but they do with this change.

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.

1 participant