Skip to content

Commit 4b52b02

Browse files
Merge pull request #3616 from AayushSabharwal/as/safety-error
refactor: add error message for wrapped variable in `collect_var!`
2 parents 8e53643 + 155bbc2 commit 4b52b02

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/utils.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,17 @@ end
606606

607607
function collect_var!(unknowns, parameters, var, iv; depth = 0)
608608
isequal(var, iv) && return nothing
609+
if Symbolics.iswrapped(var)
610+
error("""
611+
Internal Error. Please open an issue with an MWE.
612+
613+
Encountered a wrapped value in `collect_var!`. This function should only ever \
614+
receive unwrapped symbolic variables. This is likely a bug in the code generating \
615+
an expression passed to `collect_vars!` or `collect_scoped_vars!`. A common cause \
616+
is using `substitute` or `fast_substitute` with rules where the values are \
617+
wrapped symbolic variables.
618+
""")
619+
end
609620
check_scope_depth(getmetadata(var, SymScope, LocalScope()), depth) || return nothing
610621
var = setmetadata(var, SymScope, LocalScope())
611622
if iscalledparameter(var)

0 commit comments

Comments
 (0)