Support unions in Crystal::Macros::ASTNode#is_a?
#12086
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements part of #11981. This now works:
It contains a rather basic implementation of the type system of the macro language, supporting unions and
NoReturn
. Generics will be added later. There is a lot of room for optimizing the unions, but they can only be created through explicit|
s so the impact is probably low.As a reminder,
ASTNode#class_name
is never affected by this type system, whether that AST node is documented or not. ThusCrystal::Program#define_macro_types
should define everything that may possibly appear within the macro language (#3274 (comment)), so that things like{{ x.is_a?(ClassDef) }}
do not break afterwards. Everything else (e.g.Int32
) implicitly names the macroNoReturn
.