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

Add Union type #2736

Merged
merged 1 commit into from
Jun 3, 2016
Merged

Add Union type #2736

merged 1 commit into from
Jun 3, 2016

Conversation

asterite
Copy link
Member

@asterite asterite commented Jun 3, 2016

After this comment I thought it a bit more and came to the conclusion that even though a method in Union wouldn't make sense, a class method makes sense, and this is the key to implement union related stuff.

Fixes #2659 . Fixes #2727 . Related to #2714 (doesn't fix it because we are still missing YAML support, but we don't have parse_raw for YAML)

Foo(Char | String).bar
),
"can't lookup type in union (Char | String)"
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this would now always look up in Union?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do UnionType::T it gives you the T (the union type). Otherwise it searches in the program. Originally it gave an error when not using T, but the problem is that inside a Union method one wants Int32 and other types to be found.

Hmmm... it's a border case which I think doesn't matter, but now that you mention it, I think it can be done in a better way. I'll try to revive that spec. In fact, the new error was "undefined constant T::Bar" or something like that, which is the correct error message after all. Thanks for checking this, @jhass

Verified

This commit was signed with the committer’s verified signature. The key has expired.
@asterite asterite merged commit a3c5d7a into master Jun 3, 2016
@asterite asterite deleted the feature/union branch June 3, 2016 18:10
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.

[RFC] Add syntax to refer to a type
3 participants