You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is because the visitor for NodeCollector tweaks the parent tracking only in visit_*_item. This makes it not so useful for lints and such, which might want to determine what context something is in.
As far as I can tell, internally it's only called on nodes which were items in the first place (and thus their real parents will also be items except in cases where the item is inside a block) so perhaps this wasn't designed with lints in mind.
Can we make it consider all node types as possible parents? We can add an nearest_parent_item which can be used to replace all internal usage of the method if necessary.
ast_map::Map::get_parent
seems to only get the nearest ancestorItem
.This is because the visitor for
NodeCollector
tweaks the parent tracking only invisit_*_item
. This makes it not so useful for lints and such, which might want to determine what context something is in.As far as I can tell, internally it's only called on nodes which were items in the first place (and thus their real parents will also be items except in cases where the item is inside a block) so perhaps this wasn't designed with lints in mind.
Can we make it consider all node types as possible parents? We can add an
nearest_parent_item
which can be used to replace all internal usage of the method if necessary.cc @nrc
The text was updated successfully, but these errors were encountered: