Skip to content

Commit badfb9f

Browse files
fix: improve type-stability of the Initial operator
1 parent 9161395 commit badfb9f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/systems/abstractsystem.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -511,15 +511,16 @@ function (f::Initial)(x)
511511
end
512512
# don't double wrap
513513
iscall(x) && operation(x) isa Initial && return x
514-
result = if symbolic_type(x) == ArraySymbolic()
515-
term(f, x; type = symtype(x), shape = SU.shape(x))
516-
elseif iscall(x) && operation(x) == getindex
514+
sh = SU.shape(x)
515+
result = if SU.is_array_shape(sh)
516+
term(f, x; type = symtype(x), shape = sh)
517+
elseif iscall(x) && operation(x) === getindex
517518
# instead of `Initial(x[1])` create `Initial(x)[1]`
518519
# which allows parameter indexing to handle this case automatically.
519520
arr = arguments(x)[1]
520521
f(arr)[arguments(x)[2:end]...]
521522
else
522-
term(f, x; type = symtype(x), shape = SU.shape(x))
523+
term(f, x; type = symtype(x), shape = sh)
523524
end
524525
# the result should be a parameter
525526
result = toparam(result)

0 commit comments

Comments
 (0)