1
0
mirror of https://github.com/golang/go synced 2024-09-28 17:24:28 -06:00

go/types, types2: don't crash when using trace with an invalid argument

This only affects tests, typically manual tests, but when using trace
we're debugging and we don't want to crash because of trace itself.

No test because a test would cause trace output. Manually verified.

Fixes #60649.

Change-Id: I97abdb94db05774801ec5da56171f4a1aff35615
Reviewed-on: https://go-review.googlesource.com/c/go/+/501415
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
This commit is contained in:
Robert Griesemer 2023-06-06 18:46:29 -07:00 committed by Gopher Robot
parent d6d0fec43d
commit ea51e92c8a
2 changed files with 6 additions and 0 deletions

View File

@ -893,6 +893,9 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
check.dump("%v: %s", atPos(x1), x1)
x1 = &t // use incoming x only for first argument
}
if x.mode == invalid {
return
}
// trace is only available in test mode - no need to record signature
default:

View File

@ -892,6 +892,9 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
check.dump("%v: %s", x1.Pos(), x1)
x1 = &t // use incoming x only for first argument
}
if x.mode == invalid {
return
}
// trace is only available in test mode - no need to record signature
default: