Don’t let ItemRepPriorityQueue yield items more than once #1633
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Detailed description
It is possible, though unlikely, for the
ItemRepPriorityQueue
to yield an item more than once.This happens when an item rep has a dependency on an item that was previously yielded but could not be compiled due to a dependency it had itself. For example, given items A to E:
The order of yielding should be:
Previously, item A would be yielded twice: once in step 4 (when it was prioritised) and once near the end (in step 7 or 8). This is because item A ended up being deprioritised (in step 1) but it wasn’t taken into account that in the mean time, it could have been a dependency of some other item, and thus be compiled before ending up in step 7 or 8.
This is a bit mind-bending to wrap one’s head around, which is why there is a test case for this now.
To do
Future improvements could probably include folding
@seen
and@completed
into one, and making@prio_a
a nullable object instead of an array.Related issues
This is a likely fix for #1631.