Skip to content

AF1.1 Fix changing loop iteratee during iteration#212

Merged
shenkeyao merged 1 commit intocelo-integration-rebase-13.2from
keyao/fix-loop
Aug 22, 2025
Merged

AF1.1 Fix changing loop iteratee during iteration#212
shenkeyao merged 1 commit intocelo-integration-rebase-13.2from
keyao/fix-loop

Conversation

@shenkeyao
Copy link
Copy Markdown
Member

Closes https://app.asana.com/1/1208976916964769/project/1209392461754458/task/1211106994726375?focus=true.

This PR:

  • Caches the keys when processing the batch list, then deletes them at once.

@QuentinI
Copy link
Copy Markdown
Collaborator

Isn't this supposed to be safe to do in Go?

https://go.dev/ref/spec#For_range

If a map entry that has not yet been reached is removed during iteration, the corresponding iteration value will not be produced

@Ayiga
Copy link
Copy Markdown
Member

Ayiga commented Aug 22, 2025

The relevant section @QuentinI is referencing:

  1. The iteration order over maps is not specified and is not guaranteed to be the same from one iteration to the next. If a map entry that has not yet been reached is removed during iteration, the corresponding iteration value will not be produced. If a map entry is created during iteration, that entry may be produced during the iteration or may be skipped. The choice may vary for each entry created and from one iteration to the next. If the map is nil, the number of iterations is 0.

It is safe to remove entries that have not yet been encountered. That being said, I would likely still prefer to not take advantage of such a feature, and be consistent with other languages in this case.

@shenkeyao shenkeyao merged commit 2c02767 into celo-integration-rebase-13.2 Aug 22, 2025
25 checks passed
@shenkeyao shenkeyao deleted the keyao/fix-loop branch August 22, 2025 17:59
dailinsubjam pushed a commit that referenced this pull request Oct 4, 2025
dailinsubjam pushed a commit that referenced this pull request Oct 7, 2025
shenkeyao added a commit that referenced this pull request Jan 15, 2026
shenkeyao added a commit that referenced this pull request Feb 2, 2026
shenkeyao added a commit that referenced this pull request Feb 10, 2026
shenkeyao added a commit that referenced this pull request Feb 12, 2026
QuentinI pushed a commit that referenced this pull request Feb 20, 2026
shenkeyao added a commit that referenced this pull request Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants