Skip to content

Commit

Permalink
improve defensive check
Browse files Browse the repository at this point in the history
Co-authored-by: Supun Setunga <[email protected]>
  • Loading branch information
turbolent and SupunS committed Nov 21, 2024
1 parent a1f9e8b commit 39f6655
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion runtime/sema/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}

Expand Down

0 comments on commit 39f6655

Please sign in to comment.