diff --git a/runtime/sema/checker.go b/runtime/sema/checker.go index 5f4653784..9747258d9 100644 --- a/runtime/sema/checker.go +++ b/runtime/sema/checker.go @@ -2617,7 +2617,7 @@ func (checker *Checker) visitExpressionWithForceType( // Check for errors first, which is cheap, // before checking for an invalid type, which is more expensive. - if len(checker.errors) == 0 && actualType.IsInvalidType() { + if len(checker.errors) == 0 && (actualType.IsInvalidType() || (expectedType != nil && expectedType.IsInvalidType())) { panic(errors.NewUnexpectedError("invalid type produced without error")) }