From a10fe1283009e27d7499ce4d3239bfcaf3046b33 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Wed, 15 Jul 2026 04:20:31 -0400 Subject: [PATCH] Keep static failure solutions cache-free Co-Authored-By: Chris Rackauckas --- src/common.jl | 4 ++-- test/Core/lightweight_solution.jl | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/common.jl b/src/common.jl index fe674fdc3..8ddd9d1c5 100644 --- a/src/common.jl +++ b/src/common.jl @@ -775,7 +775,7 @@ function SciMLBase.solve( # with the (zero-)initialized `u` instead of throwing. u = prob.u0 !== nothing ? prob.u0 : __init_u0_from_Ab(prob.A, prob.b) return SciMLBase.build_linear_solution( - alg, u, nothing, prob; retcode = ReturnCode.Failure + alg, u, nothing, nothing; retcode = ReturnCode.Failure ) end u = F \ prob.b @@ -790,7 +790,7 @@ function SciMLBase.solve( if !gesv_ok u = prob.u0 !== nothing ? prob.u0 : __init_u0_from_Ab(prob.A, prob.b) return SciMLBase.build_linear_solution( - alg, u, nothing, prob; retcode = ReturnCode.Failure + alg, u, nothing, nothing; retcode = ReturnCode.Failure ) end elseif alg isa QRFactorization diff --git a/test/Core/lightweight_solution.jl b/test/Core/lightweight_solution.jl index 5f9cb2869..60060b1bf 100644 --- a/test/Core/lightweight_solution.jl +++ b/test/Core/lightweight_solution.jl @@ -1,4 +1,4 @@ -using LinearSolve, LinearAlgebra, SparseArrays, StableRNGs, Test +using LinearSolve, LinearAlgebra, SparseArrays, StableRNGs, StaticArrays, Test # LinearSolve 5.0: `solve!`/`solve` return a lightweight `LinearSolution` that # no longer carries the `LinearCache` (`sol.cache === nothing`). Anyone who @@ -49,6 +49,14 @@ rng = StableRNG(7) # also returns a cache-free solution sol = solve!(init(LinearProblem(copy(Asing), copy(b)), nothing; verbose = false)) @test sol.cache === nothing + + Astatic = @SMatrix [1.0 1.0; 1.0 1.0] + bstatic = @SVector [1.0, 1.0] + for alg in (LUFactorization(), GESVFactorization()) + sol = solve(LinearProblem(Astatic, bstatic), alg) + @test sol.retcode == ReturnCode.Failure + @test sol.cache === nothing + end end @testset "warm aliased refactorize+solve loop is allocation-free" begin