Please see PSA: how to quote code with backticks.
That eval
operates on global scope. From what you have shown so far there is no need for any of this parse
+ eval
stuff, just do something like:
mutable struct MyType
a::Int
b::Int
end
function foo!(B::MyType)
var1 = "b = 10" # from data file
sym, val = strip.(split(var1, "="))
setproperty!(B, Symbol(sym), parse(Int, val))
end
with the result
julia> B = MyType(1, 2)
MyType(1, 2)
julia> foo!(B)
10
julia> B # B.b has been changed
MyType(1, 10)