Well, it turns out that this is more of a bug than feature.
Discourse discussion: Confused by behaviour of nested functions
And related github issue: disallow methods of local functions in different blocks · Issue #15602 · JuliaLang/julia · GitHub
I think in an issue it is explained better than I can do.