Treat a quoted Symbol callee as a name in normalize_defsig#149
Merged
Conversation
In buggy user code,
function f(list)
m = zeros(3, 3)
m[:, :length(list)]
end
the intended call `length(list)` is a Symbol instead of a function. This
caused `normalize_defsig` to throw, and led to a Revise bug,
timholy/Revise.jl#914. A bare Symbol has no `nameof` method, so walking
the body threw `MethodError: no method matching nameof(::Symbol)` and
aborted `includet`.
A quoted Symbol is already a name, so use it directly and reserve
`nameof` for QuoteNodes wrapping functions, types, or modules. With
this, such code loads and instead fails at call time with the clear
runtime error the user expects. This is the same behavior exhibited as
if the code had been `include`d rather than `includet`ed, and this is
the contract that `includet` should uphold.
Fixes timholy/Revise.jl#914.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Member
Author
|
Nightly failure is independent (present already on |
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.
In buggy user code,
the intended call
length(list)is a Symbol instead of a function. This causednormalize_defsigto throw, and led to a Revise bug, timholy/Revise.jl#914. A bare Symbol has nonameofmethod, so walking the body threwMethodError: no method matching nameof(::Symbol)and abortedincludet.A quoted Symbol is already a name, so use it directly and reserve
nameoffor QuoteNodes wrapping functions, types, or modules. With this, such code loads and instead fails at call time with the clear runtime error the user expects. This is the same behavior exhibited as if the code had beenincluded rather thanincludeted, and this is the contract thatincludetshould uphold.Fixes timholy/Revise.jl#914.