Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

Define for-each iteration when the underlying list is modified? #82

Closed
anba opened this issue Jan 11, 2023 · 2 comments · Fixed by #86
Closed

Define for-each iteration when the underlying list is modified? #82

anba opened this issue Jan 11, 2023 · 2 comments · Fixed by #86

Comments

@anba
Copy link

anba commented Jan 11, 2023

The main spec never uses for each element iteration when the iterated-over list can be modified. Therefore it's not quite clear what the intended semantics should be, i.e. are newly added elements visible or not? Maybe it's necessary to rewrite this to an index-based loop.

The modification can happen either through user-code, e.g. in Set.prototype.intersection when calling otherRec.[[Has]]. Or it can happen through direct modification, e.g. in Set.prototype.difference when an element is removed from resultSetData during iteration over resultSetData.

@bakkot
Copy link
Collaborator

bakkot commented Jan 11, 2023

Good catch. The main spec actually did do this until recently, but I changed it to be index-based for just this reason. I'll change it here as well.

@zloirock
Copy link
Contributor

It seems here should be used an approach similar to Set.prototype.forEach for avoiding cases like #83.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants