[ty] Fix panic when attempting to provide autocompletions for an instance of a class that assigns attributes to self[0]#18707
Conversation
a0a0fd2 to
bfea391
Compare
|
sharkdp
left a comment
There was a problem hiding this comment.
Thank you!
I wondered if matches!(place_expr.sub_segments(), &[PlaceExprSubSegment::Member(_)]) should be a method on PlaceExpr, but it already has PlaceExpr::is_instance_attribute and PlaceExpr::is_instance_attribute_named with subtly different meanings. But maybe that's an argument for doing it (and clarifying the difference in doc comments)?
Good call. I added some higher-level abstractions to |
daaf192 to
8ee9597
Compare
|
Thank you for the update, this is great! |
Summary
Ty currently panics when attempting to provide autocompletions in this scenario:
The root cause of this issue is that we're incorrectly registering the
[0].is_zeroplace as an "instance attribute"Place.Places should only be registered as instance attributes if they have the formself.<NAME>;self<SUBSCRIPT>.<NAME>does not constitute an instance attribute.This panic was uncovered by #18705.
Test Plan
I added the above repro as a test to
ty_ide/completions.rs