From 41b75a7dfb0cca9fa8cfeaec08f61d4086aefecc Mon Sep 17 00:00:00 2001 From: Tristan Swadell Date: Fri, 23 Aug 2019 13:59:00 -0700 Subject: [PATCH] Add a base case for type assignability to prevent infinite recursion. --- checker/types.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/checker/types.go b/checker/types.go index 63efa202..2d716e0b 100644 --- a/checker/types.go +++ b/checker/types.go @@ -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 {