From f31de50abcfbbf70ed3095a3bc20b9a070cfabef Mon Sep 17 00:00:00 2001 From: "M.V. Hutz" Date: Sun, 18 Jan 2026 15:57:28 -0500 Subject: [PATCH] fix: use loop variable instead of global ticker in GenerateFreshName The function used a global `ticker` variable but never incremented it inside the loop, causing an infinite loop if the first generated name was already in the used set. This fix removes the global state and uses the loop variable `i` directly, which is cleaner and avoids the bug. --- pkg/lambda/generate_name.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkg/lambda/generate_name.go b/pkg/lambda/generate_name.go index fbfa898..03f5018 100644 --- a/pkg/lambda/generate_name.go +++ b/pkg/lambda/generate_name.go @@ -6,13 +6,11 @@ import ( "git.maximhutz.com/max/lambda/pkg/set" ) -var ticker uint64 = 0 - // GenerateFreshName generates a variable name that is not in the used set. // This function does not mutate the used set. func GenerateFreshName(used set.Set[string]) string { for i := uint64(0); ; i++ { - attempt := "_" + string(strconv.AppendUint(nil, ticker, 10)) + attempt := "_" + string(strconv.AppendUint(nil, i, 10)) if !used.Has(attempt) { return attempt -- 2.49.1