Open nsajko opened 1 year ago
There's a Discourse thread here: https://discourse.julialang.org/t/weird-behavior-for-types-within-type-definitions/99581
For what it's worth, it seems to me that, if possible, constructions like these should just be disallowed.
Disallowing might be reasonable if not breaking, otherwise everything ending up global seems maybe (?) ok to me since modules are the only way I imagine types being kept from global scope
Furthermore, the existence of the inner type seems to inhibit the creation of a constructor for the outer type, which seems inconsistent with the fact that the inner type is not restricted to the outer type's scope (or whatever that's called).
I believe almost any non-field syntax in a struct ... end
definition inhibits the default constructor.
I agree that could probably use some tightening up and a proper spelling (@noconstructor
?), but it'd also arguably be breaking.
It seems that defining types in a nested manner inside other type definitions exposes the inner types as global names, even though no
global
was used.Furthermore, the existence of the inner type seems to inhibit the creation of a constructor for the outer type, which seems inconsistent with the fact that the inner type is not restricted to the outer type's scope (or whatever that's called).
Reproducible on master.