-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix instantiation errors with generic
=deepCopy
(#895)
## Summary Fix "unresolved generic parameter" error occurring when instantiating generic `=deepCopy` implementations that create locals of the instantiated type the generic operator is instantiated for. ## Details A generic `=deepCopy` operator attached to a generic type is instantiated when an instance of the generic type is created. At the end of instantiating body of the operator, the second semantic pass (`sempass2`) lifts the type-bound operators for types used in the body. If the type the generic `=deepCopy` operator is instantiated for is used in the body, this means that the other type-bound operators are also lifted already. However, if one of the other type-bound operators is generic, this leads to `liftdestructors.inst` being called, which then reports an `rsemUnresolvedGenericParameter` error, as `typeInst` is nil. The reason for `typeInst` being 'nil' at this point is that `handleGenericInvocation`, from where the generic `=deepCopy` is instantiated, only assigns the `typeInst` field *after* the hook is instantiated. The `typeInst` field for an instantiation is now set *before* instantiating the generic `=deepCopy` operator, fixing the issue. In addition, `typeInst` not being set when trying to instantiate a generic type-bound operator is changed to an internal error (`unreachable`) and the `rsemUnresolvedGenericParameter` report is removed. --------- Co-authored-by: Saem Ghani <saemghani+github@gmail.com>
- Loading branch information
Showing
5 changed files
with
38 additions
and
11 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