-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Method/macro parameter annotation support #12044
Method/macro parameter annotation support #12044
Conversation
|
||
def foo( | ||
id : Int32, | ||
@[Ann] &block : Int32 -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related: #5334
Seems something is broken with I'll see if I can figure out what's wrong tomorrow. EDIT: Seems a single |
Reset arg type after processing an `Arg`, versus a `Def`
Bump. Another review on this would be much appreciated 🙂. |
How's the memory consumption after this PR for, say, compiling the compiler? You can check this with "-s" |
On this branch:
On the commit I branched off of:
So seems pretty much the same? |
Interesting! Since we are adding something to every |
@@ -1010,8 +1010,9 @@ module Crystal | |||
property default_value : ASTNode? | |||
property restriction : ASTNode? | |||
property doc : String? | |||
property parsed_annotations : Array(Annotation)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of keeping the annotations on each arg, I think we can move this to the Def
and Macro
objects, similar to how the splat index is kept there.
But we could do this refactor later on if we see memory issues. I just don't think that annotations on args will be that common, and so adding this overhead to every arg instead of adding just a nilable attribute to Def
and Macro
might be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Also added an optional focus parameter to assert_format to make debugging a specific failure a bit easier. Fixes formatter after #12044.
Also added an optional focus parameter to assert_format to make debugging a specific failure a bit easier. Fixes formatter after crystal-lang#12044.
Also added an optional focus parameter to assert_format to make debugging a specific failure a bit easier. Fixes formatter after #12044.
Also added an optional focus parameter to assert_format to make debugging a specific failure a bit easier. Fixes formatter after #12044.
Resolves #12039
to_s
Based on #9322 (comment) i took a bit of a diff approach and stored the parsed annotation instances within the
Arg
node itself. Ended up making the implementation much easier and figured we wouldn't have to worry about breaking compatibility since this is a new feature.