I've been looking into fixing SR-13766, which is an issue I discovered while working on Periphery. In a nutshell, the type of a property is not associated with the property itself. Specifically, the type reference does not have 'container' relationship with the property declaration. For the purpose of identifying unused code, this is problematic, as it's not possible to determine if the type of an non-referenced property is itself also not referenced.
Initially I assumed this was an issue in lib/index/Index.cpp, however I now know that it's actually due to the AST structure.
PatternBindingDecl is not scoped within
VarDecl, but is instead inserted into the parent scope of the
VarDecl, e.g a
StructDecl. This leads me to believe that this is in fact by design - why is that?
Conversely, the return type, and parameter types of functions are scoped within the function declaration, yet one could argue (from a syntactic perspective at least) that their scoping is the same as a property type's is to a property.
I'm sure I must be missing a crucial piece of the bigger picture here...