From 997b6969fd7be64a03255ef998981de716aa4313 Mon Sep 17 00:00:00 2001 From: David Chase Date: Wed, 22 May 2024 16:00:29 -0400 Subject: internal/abi, cmd/compile, runtime: deduplicate rangefunc consts Change-Id: I61ec5a7fa0c10f95ae2261c3349743d6fda2c1d2 Reviewed-on: https://go-review.googlesource.com/c/go/+/587596 LUCI-TryBot-Result: Go LUCI Reviewed-by: Keith Randall Reviewed-by: Keith Randall Auto-Submit: Keith Randall --- src/runtime/panic.go | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'src/runtime') diff --git a/src/runtime/panic.go b/src/runtime/panic.go index 9a710f6edf..e182b0b733 100644 --- a/src/runtime/panic.go +++ b/src/runtime/panic.go @@ -304,21 +304,14 @@ var rangeMissingPanicError = error(errorString("range function recovered a loop //go:noinline func panicrangestate(state int) { - const ( - // These duplicate magic numbers in cmd/compile/internal/rangefunc - DONE = 0 // body of loop has exited in a non-panic way - PANIC = 2 // body of loop is either currently running, or has panicked - EXHAUSTED = 3 // iterator function return, i.e., sequence is "exhausted" - MISSING_PANIC = 4 // body of loop panicked but iterator function defer-recovered it away - ) - switch state { - case DONE: + switch abi.RF_State(state) { + case abi.RF_DONE: panic(rangeDoneError) - case PANIC: + case abi.RF_PANIC: panic(rangePanicError) - case EXHAUSTED: + case abi.RF_EXHAUSTED: panic(rangeExhaustedError) - case MISSING_PANIC: + case abi.RF_MISSING_PANIC: panic(rangeMissingPanicError) } throw("unexpected state passed to panicrangestate") -- cgit v1.3-5-g9baa