commit 4da080df88248875f8be0bb4ae44857d3fb0925c
parent 05504b3c7e83eb54a4387bfe2e379b77863daae2
Author: lash <dev@holbrook.no>
Date: Thu, 5 Sep 2024 16:01:17 +0100
Stop endless catch recursion with panic :O
Diffstat:
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/state/state.go b/state/state.go
@@ -273,10 +273,16 @@ func(st *State) Top() (bool, error) {
// Clears mapping and sink.
func(st *State) Down(input string) error {
var n uint16
- if len(st.ExecPath) > MaxLevel {
+ l := len(st.ExecPath)
+ if l > MaxLevel {
panic("maxlevel")
return fmt.Errorf("max levels exceeded (%d)", n)
}
+ if l > 0 {
+ if st.ExecPath[l-1] == input {
+ panic("down into same node as previous")
+ }
+ }
st.ExecPath = append(st.ExecPath, input)
st.SizeIdx = 0
st.Moves += 1