Skip to content

Commit ef773bf

Browse files
Merge pull request #120 from SciML/as/remake-buffer-bug
fix: fix stack overflow on `remake_buffer` of `Dict`
2 parents c6bc78c + 655fc2c commit ef773bf

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/remake.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ function remake_buffer(sys, oldbuffer::AbstractArray, idxs, vals)
5555
return newbuffer
5656
end
5757

58+
# We don't support `Dict`s as value providers. If we get a `Dict`,
59+
# assume it is non-symbolic.
60+
function remake_buffer(sys, oldbuffer::Dict, idxs, vals)
61+
return Dict(idxs .=> vals)
62+
end
63+
5864
remake_buffer(sys, ::Nothing, idxs, vals) = nothing
5965

6066
function remake_buffer(sys, oldbuffer, idxs, vals)

test/remake_test.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,12 @@ for (buf, newbuf, idxs, vals) in [
7373
end
7474

7575
@test isnothing(remake_buffer(sys, nothing, [], []))
76+
77+
@testset "`remake_buffer` with `Dict`" begin
78+
sys = nothing
79+
buf = Dict("a" => 1, "b" => 2)
80+
buf2 = remake_buffer(sys, buf, collect(keys(buf)), collect(values(buf)))
81+
@test isequal(buf, buf2)
82+
buf2 = remake_buffer(sys, buf, buf)
83+
@test isequal(buf, buf2)
84+
end

0 commit comments

Comments
 (0)