Skip to content

refactor: add error message for wrapped variable in collect_var! #3616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,17 @@ end

function collect_var!(unknowns, parameters, var, iv; depth = 0)
isequal(var, iv) && return nothing
if Symbolics.iswrapped(var)
error("""
Internal Error. Please open an issue with an MWE.

Encountered a wrapped value in `collect_var!`. This function should only ever \
receive unwrapped symbolic variables. This is likely a bug in the code generating \
an expression passed to `collect_vars!` or `collect_scoped_vars!`. A common cause \
is using `substitute` or `fast_substitute` with rules where the values are \
wrapped symbolic variables.
""")
end
check_scope_depth(getmetadata(var, SymScope, LocalScope()), depth) || return nothing
var = setmetadata(var, SymScope, LocalScope())
if iscalledparameter(var)
Expand Down
Loading