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

Support typed parameters inside unions #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rdeits
Copy link
Contributor

@rdeits rdeits commented Apr 17, 2017

Note: this is my first time working with the internals of MacroTools. I may have done something wrong. I'd appreciate as much review attention as you can spare.

This supports typed parameters inside unions for the @match macro (fixes #36 ) by cleaning up some of the quoting procedures inside types.jl. The one sketchy part is that I call eval() in types.jl to convert :Symbol into the type Symbol. That feels wrong to me, and it may be possible to avoid it.

The ensurequoted method in macro.jl exists so that subtb can return a TypeBind directly instead of an expression that somehow interpolates to a TypeBind, while still working with plain Expr and Symbol inputs.

@MikeInnes
Copy link
Member

Good stuff! So you're right that the core issue is the inconsistency in the way unions are emitted (as objects) vs type bindings (as expressions). However, I think the right solution to this is actually to go the other way around and have everything be an expression, rather than everything be an object. That should lead to a simpler change that solves all the issues in one fell swoop, and without the eval hack. Let me know if you need more details.

FWIW, I don't think the ensurequote should be necessary here; quoting a non-expression shouldn't have any effect AFAIK.

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.

Match failure when combining Unions and expression types
2 participants