Repository navigation
Recognize GlobalRef callees in ismethod_with_name and remove is_Typeof_for_anonymous_methoddef - #170
Merged
Merged
Conversation
…Typeof_for_anonymous_methoddef` `ismethod_with_name` recognized calls to `Core.svec`, `Core.Typeof`, `Core.apply_type` and `UnionAll` only when the callee was a `QuoteNode`. JuliaInterpreter produces that form only when it folds `const` globals: for optimized frames, and on Julia 1.12+ not in top-level code. Without folding, the callees are `GlobalRef`s. For example, on Julia 1.12+ `ismethod_with_name` failed to find `Foo` in the signature of `(::Foo)(x) = x`. On Julia 1.10, the selective evaluation of `struct NoParam end` in the tests broke for a frame built with `optimize=false`. Match the callees with `callee_matches`, which accepts both forms, as the other callee checks in this package already do. `is_Typeof_for_anonymous_methoddef` had the same problem, but is removed instead. It made `signature` return `nothing` on reaching `Core.Typeof(name)` for an undefined `name`, so that `rename_framemethods!` left the name of a gensymmed method as it is when the method's caller is not defined. Since Julia 1.11, lowering loads `name` in a separate statement that `Core.Typeof` refers to. `signature` evaluates that statement first and throws an `UndefVarError` before it reaches the check, so the check no longer fires. This was the warning reported in #110. #111 fixed it by having `set_to_running_name!` catch the `UndefVarError`, which leaves the name as it is, the same result the check gives. The check still fires on Julia 1.10, but the catch handles those cases as well. The only difference is that `signature(frame, pc)` throws in such a case on Julia 1.10, as it already does on Julia 1.11+. The LoweredCodeUtils tests pass on Julia 1.13 and 1.10, including with a JuliaInterpreter that never folds `const` globals. The Revise test suite gives the same results as before on Julia 1.13 and 1.10, without new warnings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On Julia 1.14, lowering defines methods with `Core.define_method(mod, name, sigdata, codeinfo)` calls instead of 3-argument `:method` expressions. For a method without a name, `ismethod_with_name` walks the signature to find the target name, but it took the signature only from a `:method` expression. It thus missed the name in the `define_method` form, e.g. `Callable` in the signature of `(::Callable)(x) = x`, which the test added in the previous commit caught on nightly. Add `method_sig`, which returns the signature data of either form, and use it in `ismethod_with_name` and `signature_top`, which already handled both forms inline. The LoweredCodeUtils tests pass on Julia 1.14.0-DEV.3439, 1.13 and 1.10. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
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.
ismethod_with_namerecognized calls toCore.svec,Core.Typeof,Core.apply_typeandUnionAllonly when the callee was aQuoteNode. JuliaInterpreter produces that form only when it foldsconstglobals: for optimized frames, and on Julia 1.12+ not in top-level code. Without folding, the callees areGlobalRefs. For example, on Julia 1.12+ismethod_with_namefailed to findFooin the signature of(::Foo)(x) = x. On Julia 1.10, the selective evaluation ofstruct NoParam endin the tests broke for a frame built withoptimize=false. Match the callees withcallee_matches, which accepts both forms, as the other callee checks in this package already do.is_Typeof_for_anonymous_methoddefhad the same problem, but is removed instead. It madesignaturereturnnothingon reachingCore.Typeof(name)for an undefinedname, so thatrename_framemethods!left the name of a gensymmed method as it is when the method's caller is not defined. Since Julia 1.11, lowering loadsnamein a separate statement thatCore.Typeofrefers to.signatureevaluates that statement first and throws anUndefVarErrorbefore it reaches the check, so the check no longer fires. This was the warning reported in #110. #111 fixed it by havingset_to_running_name!catch theUndefVarError, which leaves the name as it is, the same result the check gives. The check still fires on Julia 1.10, but the catch handles those cases as well. The only difference is thatsignature(frame, pc)throws in such a case on Julia 1.10, as it already does on Julia 1.11+.The LoweredCodeUtils tests pass on Julia 1.13 and 1.10, including with a JuliaInterpreter that never folds
constglobals. The Revise test suite gives the same results as before on Julia 1.13 and 1.10, without new warnings.