fix: resolve TreeRef element types in settype! instead of crashing#154
Merged
Conversation
Indexing or iterating a `Vector{T}` whose element type `T` is a struct
defined in a sibling file resolves `T` to a `TreeRef` in per-file
analysis mode. `infer_eltype` handed that `TreeRef` to `settype!`, but
`Binding.type` is `Union{Binding,SymStore,Nothing}` and can't hold one,
so `convert` threw and took down the whole file-analysis derived query.
Route any `TreeRef` second arg to a dedicated `settype!` method that
resolves an external datatype through the env (so `Vector{PkgId}` now
infers `PkgId`) and drops anything unresolvable (a workspace struct,
declared in another file's tree) rather than assigning it. `state` is
an optional third arg on every `settype!` method so callers pass it
uniformly and a stray `TreeRef` can never reach `b.type = type`.
Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Indexing or iterating a
Vector{T}whose element typeTis a struct defined in a sibling file resolvesTto aTreeRefin per-file analysis mode.infer_eltypehanded thatTreeReftosettype!, butBinding.typeisUnion{Binding,SymStore,Nothing}and can't hold one, soconvertthrew and took down the whole file-analysis derived query.Route any
TreeRefsecond arg to a dedicatedsettype!method that resolves an external datatype through the env (soVector{PkgId}now infersPkgId) and drops anything unresolvable (a workspace struct, declared in another file's tree) rather than assigning it.stateis an optional third arg on everysettype!method so callers pass it uniformly and a strayTreeRefcan never reachb.type = type.