With the latest package versions, the @parameters macro doesn’t seem to exist (any more). I can write this:
using Symbolics, SymbolicUtils.Code
@variables z[1:3]
expr = toexpr(z[1] + z[2])
println("z[1] in expression: ", in(toexpr(z[1]), expr.args))
println("z[3] in expression: ", in(toexpr(z[3]), expr.args))
The output is
z[1] in expression: true
z[3] in expression: false