Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.4.3, 6.8
-
None
-
3244c5929 (dev), fcf76c79a (6.8)
Description
It is supposed to be safe to insert / delete elements of a set during iteration however the following code is producing different output when run in QML vs Firefox
let set = new Set([1,2,3]);
set.forEach((v) => {
console.log(v)
set.delete(v)
})
Firefox output:
1 2 3
QML output:
1 3
The spec seems to suggest that this should work:
Each value is normally visited only once. However, a value will be revisited if it is deleted after it has been visited and then re-added before the forEach call completes. Values that are deleted after the call to forEach begins and before being visited are not visited unless the value is added again before the forEach call completes. New values added after the call to forEach begins are visited.