Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a base case for type assignability to prevent infinite recursion. #250

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add a base case for type assignability to prevent infinite recursion.
TristonianJones committed Aug 23, 2019
commit 41b75a7dfb0cca9fa8cfeaec08f61d4086aefecc
5 changes: 5 additions & 0 deletions checker/types.go
Original file line number Diff line number Diff line change
@@ -179,6 +179,11 @@ func isEqualOrLessSpecific(t1 *exprpb.Type, t2 *exprpb.Type) bool {

/// internalIsAssignable returns true if t1 is assignable to t2.
func internalIsAssignable(m *mapping, t1 *exprpb.Type, t2 *exprpb.Type) bool {
// A type is always assignable to itself.
// Early terminate the call to avoid cases of infinite recursion.
if proto.Equal(t1, t2) {
return true
}
// Process type parameters.
kind1, kind2 := kindOf(t1), kindOf(t2)
if kind2 == kindTypeParam {