-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
InteractiveUtils: Fully support broadcasting expressions for code introspection macros #58349
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
Merged
topolarity
merged 13 commits into
JuliaLang:master
from
serenity4:fix-broadcast-with-kwargs
Jun 4, 2025
Merged
InteractiveUtils: Fully support broadcasting expressions for code introspection macros #58349
topolarity
merged 13 commits into
JuliaLang:master
from
serenity4:fix-broadcast-with-kwargs
Jun 4, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
topolarity
reviewed
May 23, 2025
topolarity
approved these changes
May 23, 2025
Member
topolarity
left a comment
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.
The structure looks right to me, although I didn't do a close check for correct-ness
Thanks much, @serenity4 !
Also includes another `supports_binding_reflection` parameter to remove the special-cased support for `@which` reflection into bindings.
Member
|
CI is still green here, so I'm going to take the liberty to merge this 👍 |
Member
Author
|
Thanks for the review @topolarity! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR includes a fix and a feature for code introspection macros (
@code_typed,@code_llvmand friends but not@which,@edit, etc):f.(x; y = 3), for which keyword arguments were not properly handled and led to an internal error.x .= f(y),x .<<= f.(y, z), etc.The way this was (and still is) implemented is by constructing a temporary function,
f(x1, x2, x3, ...) = <body>and feeding that to code introspection functions. This trick doesn't apply to@whichand@edit, which need to map to a single function call (we could arguably choose to targetmaterialize/materialize!, but this behavior could be a bit surprising and difficult to support).The switch differentiating the families of macro
@code_typed/@code_llvmand@which/@editetc was further exposed as an additional argument togen_call_with_extracted_typesandgen_call_with_extracted_types_and_kwargs, which default to the previous behavior (differentiating them based on whether their name starts withcode_). The intent is to allow other macros such asCthulhu.@descendto register themselves as code introspection macros. Quick tests indicate that it works as intended, e.g. with this PR Cthulhu supports@descend [1, 2] .+= [2, 3](or equivalently, as added in #57909,@descend ::Vector{Int} .+= ::Vector{Int}).I originally just went for the fix, and after some refactoring I realized the feature was very straightforward to implement.