Skip to content

Remove name shadows, dead aliases, and unused imports in linalg and broadcasting - #779

Open
ViralBShah wants to merge 1 commit into
mainfrom
vs/linalg-shadow-cleanup
Open

Remove name shadows, dead aliases, and unused imports in linalg and broadcasting#779
ViralBShah wants to merge 1 commit into
mainfrom
vs/linalg-shadow-cleanup

Conversation

@ViralBShah

Copy link
Copy Markdown
Member

Cleanup from a structural review of src/linalg.jl and src/higherorderfns.jl. No behaviour change.

Name shadows. These are the same class of bug as #769 (findprev defined locally instead of extending Base), just with internal names:

  • src/linalg.jl defined an unqualified _generic_matmatmul!, which creates a SparseArrays-local function, while the same file calls LinearAlgebra._generic_matmatmul! (qualified) for dense destinations. Two different functions with one name, 350 lines apart. The local one is renamed _generic_spmatmatmul! with a comment explaining the relationship.
  • Likewise the local _mul! used by the symmetric/Hermitian path (now _symherm_mul!) versus the extension of LinearAlgebra._mul! at the top of the file.
  • The pre-1.10 top_set_bit shim shadowed Base.top_set_bit; dropped in favour of calling Base.top_set_bit directly (the package requires Julia 1.11).
  • const DenseVecOrMat shadowed the exported Base.DenseVecOrMat with a different meaning, and was unused.

Dead code. DenseTriangular, SpBroadcasted2, and a nine-line commented-out factorize method, all with zero references.

Missing const. SparseVecOrMat (used in 32 method signatures) and SparseOrStructuredMatrix in higherorderfns.jl were plain globals, unlike the five aliases next to them.

Imports. Removed StridedMaybeAdjOrTransMat, SorF, and diagm, none of which are referenced. isbanded is called but never extended, and it is not exported by LinearAlgebra, so it moves from import to using.

Full test suite passes on nightly; Test.detect_ambiguities(SparseArrays) remains empty; whitespace check clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LgBHUw9Hp7YW5ub29B4R5y

…roadcasting

- `src/linalg.jl` defined an unqualified `_generic_matmatmul!`, creating a
  SparseArrays-local function while the same file calls
  `LinearAlgebra._generic_matmatmul!` (qualified) for dense destinations. Rename
  the local one to `_generic_spmatmatmul!`. Same for the local `_mul!` used by
  the symmetric/Hermitian path, now `_symherm_mul!`, versus the extension of
  `LinearAlgebra._mul!`.
- Drop the pre-1.10 `top_set_bit` shim (which also shadowed `Base.top_set_bit`)
  and call `Base.top_set_bit` directly.
- Remove unused aliases `DenseTriangular` and `DenseVecOrMat` (the latter
  shadowed the exported `Base.DenseVecOrMat` with a different meaning), the
  unused `SpBroadcasted2`, and a nine-line commented-out `factorize` method.
- Make `SparseVecOrMat` (used in 32 method signatures) and
  `SparseOrStructuredMatrix` in `higherorderfns.jl` `const`, like their neighbours.
- Remove unused imports: `StridedMaybeAdjOrTransMat`, `SorF`, `diagm`. Move
  `isbanded` from `import` to `using`, since it is called but never extended.

No behaviour change; full test suite passes and no new ambiguities.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LgBHUw9Hp7YW5ub29B4R5y
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.20%. Comparing base (305ac27) to head (778d464).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #779      +/-   ##
==========================================
+ Coverage   84.19%   84.20%   +0.01%     
==========================================
  Files          13       13              
  Lines        9403     9403              
==========================================
+ Hits         7917     7918       +1     
+ Misses       1486     1485       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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