Description
Indexing AbstractAlgebra.jl fails with an unhandled MethodError in cache_methods, causing the language server to crash and leaving no hover documentation or completions available for the package.
The crash occurs because AbstractAlgebra has an interaction with SymbolicUtils.jl (SymbolicUtils uses AbstractAlgebra internally). When SymbolServer loads AbstractAlgebra, a SymbolicUtils.BasicSymbolic callable object is encountered and passed to cache_methods as f. The code then calls parentmodule(f) on line 291 of symbols.jl, but parentmodule has no method for arbitrary callable objects like BasicSymbolic — only for modules, types, and regular functions.
Steps to Reproduce
- Add
AbstractAlgebra to a Julia environment: ] add AbstractAlgebra
- Open a
.jl file in VS Code with that environment active
- Observe the Language Server Output panel (View → Output → Julia Language Server)
Error Log
[ Info: Indexing AbstractAlgebra... (88%)
ERROR: LoadError: MethodError: no method matching parentmodule(::SymbolicUtils.BasicSymbolic{SymbolicUtils.FnType{Tuple{Number, Number}, Number, Nothing}})
The function `parentmodule` exists, but no method is defined for this combination of argument types.
Closest candidates are:
parentmodule(::Any, !Matched::Any)
@ Base reflection.jl:973
parentmodule(!Matched::Base.JuliaSyntax.Kind)
@ Base /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-HL2F7YQ3XH.0/build/default-honeycrisp-HL2F7YQ3XH-0/julialang/julia-release-1-dot-12/base/JuliaSyntax/src/kinds.jl:73
parentmodule(!Matched::Module)
@ Base runtime_internals.jl:21
...
Stacktrace:
[1] cache_methods(f::Any, name::Symbol, env::Dict{Symbol, Main.SymbolServer.ModuleStore}, get_return_type::Bool; min_world::UInt64)
@ Main.SymbolServer ~/.vscode/extensions/julialang.language-julia-1.219.2/scripts/packages/SymbolServer/src/symbols.jl:291
[2] cache_new_methods!(env::Dict{Symbol, Main.SymbolServer.ModuleStore}, world_before::UInt64; get_return_type::Bool)
@ Main.SymbolServer ~/.vscode/extensions/julialang.language-julia-1.219.2/scripts/packages/SymbolServer/src/symbols.jl:434
[3] top-level scope
@ ~/.vscode/extensions/julialang.language-julia-1.219.2/scripts/packages/SymbolServer/src/server.jl:143
Expected Behavior
AbstractAlgebra should be indexed successfully, with hover documentation and completions available for its exported functions (e.g. snf, snf_with_transform).
Suggested Fix
cache_methods in symbols.jl should guard the parentmodule(f) call against arbitrary callable objects that are not regular functions, modules, or types — for example with a try/catch or an applicable(parentmodule, f) check before calling it.
This is the same class of failure previously seen with MathOptInterface (issue #52).
Environment
- VS Code extension: julialang.language-julia 1.219.2
- OS: macOS (Apple Silicon)
- Julia version: 1.12.6
- Package: AbstractAlgebra v0.50.1
Description
Indexing
AbstractAlgebra.jlfails with an unhandledMethodErrorincache_methods, causing the language server to crash and leaving no hover documentation or completions available for the package.The crash occurs because
AbstractAlgebrahas an interaction withSymbolicUtils.jl(SymbolicUtils uses AbstractAlgebra internally). When SymbolServer loads AbstractAlgebra, aSymbolicUtils.BasicSymboliccallable object is encountered and passed tocache_methodsasf. The code then callsparentmodule(f)on line 291 ofsymbols.jl, butparentmodulehas no method for arbitrary callable objects likeBasicSymbolic— only for modules, types, and regular functions.Steps to Reproduce
AbstractAlgebrato a Julia environment:] add AbstractAlgebra.jlfile in VS Code with that environment activeError Log
Expected Behavior
AbstractAlgebra should be indexed successfully, with hover documentation and completions available for its exported functions (e.g.
snf,snf_with_transform).Suggested Fix
cache_methodsinsymbols.jlshould guard theparentmodule(f)call against arbitrary callable objects that are not regular functions, modules, or types — for example with atry/catchor anapplicable(parentmodule, f)check before calling it.This is the same class of failure previously seen with
MathOptInterface(issue #52).Environment