I have a code that is throwing an UndefVarError
even though the variable exists.
for code in (Struct(i) for i in Tuple(...))
@assert typeof(code.name) <: AbstractString # Error: `code` not defined
Struct()
is an imutable Struct with two fields: name and value. And the tuple is just a list of ints. I use a inner constructor for creating the name and value field from just one input, i
.
When I tested with @isdefined code
or @isdefined code.name
, or even, typeof(code.name)
, it goes fine, it prints to the terminal just fine showing that the object does in fact exists, but it always throws an error in the assert.
What is going on here?