@@ -535,7 +535,7 @@ recursively searches through all subsystems of `sys`, increasing the depth if it
535535"""
536536function collect_scoped_vars! (unknowns, parameters, sys, iv; depth = 1 , op = Differential)
537537 if has_eqs (sys)
538- for eq in get_eqs (sys)
538+ for eq in equations (sys)
539539 eqtype_supports_collect_vars (eq) || continue
540540 if eq isa Equation
541541 eq. lhs isa Union{Symbolic, Number} || continue
@@ -544,7 +544,7 @@ function collect_scoped_vars!(unknowns, parameters, sys, iv; depth = 1, op = Dif
544544 end
545545 end
546546 if has_parameter_dependencies (sys)
547- for eq in get_parameter_dependencies (sys)
547+ for eq in parameter_dependencies (sys)
548548 if eq isa Pair
549549 collect_vars! (unknowns, parameters, eq, iv; depth, op)
550550 else
@@ -553,17 +553,13 @@ function collect_scoped_vars!(unknowns, parameters, sys, iv; depth = 1, op = Dif
553553 end
554554 end
555555 if has_constraints (sys)
556- for eq in get_constraints (sys)
556+ for eq in constraints (sys)
557557 eqtype_supports_collect_vars (eq) || continue
558558 collect_vars! (unknowns, parameters, eq, iv; depth, op)
559559 end
560560 end
561561 if has_op (sys)
562- collect_vars! (unknowns, parameters, get_op (sys), iv; depth, op)
563- end
564- newdepth = depth == - 1 ? depth : depth + 1
565- for ssys in get_systems (sys)
566- collect_scoped_vars! (unknowns, parameters, ssys, iv; depth = newdepth, op)
562+ collect_vars! (unknowns, parameters, objective (sys), iv; depth, op)
567563 end
568564end
569565
608604function collect_var! (unknowns, parameters, var, iv; depth = 0 )
609605 isequal (var, iv) && return nothing
610606 check_scope_depth (getmetadata (var, SymScope, LocalScope ()), depth) || return nothing
607+ var = setmetadata (var, SymScope, LocalScope ())
611608 if iscalledparameter (var)
612609 callable = getcalledparameter (var)
613610 push! (parameters, callable)
@@ -636,7 +633,7 @@ function check_scope_depth(scope, depth)
636633 elseif scope isa ParentScope
637634 return depth > 0 && check_scope_depth (scope. parent, depth - 1 )
638635 elseif scope isa DelayParentScope
639- return depth >= scope. N && check_scope_depth (scope. parent, depth - scope. N)
636+ return depth >= scope. N && check_scope_depth (scope. parent, depth - scope. N - 1 )
640637 elseif scope isa GlobalScope
641638 return depth == - 1
642639 end
0 commit comments