-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BaseClass wraps Expr: fixes invariant violation
Summary: This commit solves a bug where Pyre was unable to correctly handle generic classes that referred to themselves in their own base classes, because it triggered recursive lookups of the type parameters that had inconsistent lengths. This happens because we have to analyze the base classes in order to *get* the type parameters, and we were doing type-level analysis. The fix is to modify `BaseClass` to be expression-level, so that we can use an AST visitor rather than a type visitor. In doing so, we can avoid ever triggering an `expr_untype` call on the current class, which bypasses the cause of the invariant violation. --------- This fix is a bit messy: we're now putting `Expr` into the `Answer` of a `Keyed` instance, which is awkward because of extra clones, because we have to define "recursive promotion" even though there's no good recursive behavior anymore, and because we need `Display` which can't really be implemented well on `Expr`. I want to punt on all these issues for this diff, because with this approach in place it becomes much easier to just roll the base classes into `Class`, which will make all of these things more tractable and also make it much easier for us to truly enforce the invariants that keep causing panics. So instead of spending time optimizing this setup I'd prefer to just move forward with that plan, which will take some effort but should yield big benefits. Reviewed By: ndmitchell Differential Revision: D66511478 fbshipit-source-id: a1e900f0ef6bb710b599d23725791ad2d051bf95
- Loading branch information
1 parent
5a26748
commit f3402bf
Showing
5 changed files
with
43 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters