Yes. It’s says so. “not at top level”. You can however run top level stuff inside a function with eval or @eval:
function f()
@eval struct Foo
a::Int
end
end
and even create it with you own name
function g(name)
@eval struct $(Symbol(name))
a::Int
end
end
g("MyStruct")