-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ruleguard/typematch: implement struct type pattern matching (#87)
struct{$*_} - arbitrary struct struct{$_; $_} - struct of any 2 fields struct{$x; $x} - struct of 2 fields of type $x struct{$*_; $x} - struct that ends with $x-typed field struct{$x; $*_} - struct that starts with $x-typed field struct{$*_; $x; $*_} - struct that contains $x-typed field This is not a direct solution for https://twitter.com/dgryski/status/1317245210041012224, but it makes us get a little closer to it. There are several interpretations of Type.Contains() and we need to decide what should be traversed and whatnot (and how deep). Until we decide on the exact Type.Contains() semantics, struct type pattern matching can be a temporary solution to this problem. I'll add analyzer tests later to see whether it really can be used in the requested context. I would expect that we need things like Type.Underlying(), etc. to make it work correctly. But that's a different story. Signed-off-by: Iskander Sharipov <[email protected]>
- Loading branch information
Showing
2 changed files
with
204 additions
and
12 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