Skip to content

fix: resolve TreeRef element types in settype! instead of crashing#154

Merged
pfitzseb merged 1 commit into
mainfrom
sp/fix-settype-treeref-crash
Jul 22, 2026
Merged

fix: resolve TreeRef element types in settype! instead of crashing#154
pfitzseb merged 1 commit into
mainfrom
sp/fix-settype-treeref-crash

Conversation

@pfitzseb

Copy link
Copy Markdown
Member

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.

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>
@pfitzseb
pfitzseb merged commit aa5e0e4 into main Jul 22, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant