-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zip does not work when arguments are list and some other Iterator #2140
Comments
@sydow isn't this your domain? Going via a list() should not make a difference, I think. Why is it? Surely there must be some simple fix here, right? :) Like it looks like all the protocols etc are lined up for this to work, yet it doesn't... |
I spent quite some time today to look at this. I immediately found an easy (and recent) bug, but the problem was not solved. It took me a long time to find the other problem, which I hope @nordlander can fix easily. The first problem is that zip was not adapted to the change in iterators. Here is zip_next in
Obviously this is from the time when iterations were NULL-terminated and was missed in the conversion. The if-statement must be replaced by just
The second problem was more difficult to find. But look at the example; zip is applied to two arguments, a list (sides) and an iterator (reverse(sides)). Both these are of types that implement Iterable. Here is the generated C code (partial):
Note that W_16 is the witness that Iterators implement Iterable and W_17 the witness that lists implement Iterable. So the order of these two parameters seems to have been mixed up; it seems obvious that the 1st and 3rd parameters belong together and the 2nd and 4th. But then it is difficult to understand that this error hasn't showed up much earlier? (Note that the outcommented example works since the two witnesses are the same). I hope Johan can easily see where some list of parameters is not reversed when it should have been (or conversely). I should add that the problem is introduced early, already during type-checking, but that is not surprising. |
Acton Version
0.24.1.20250129.19.42.50
Steps to Reproduce and Observed Behavior
The code compiles, but does not enter the for loop and print out expected:
If we instead "materialize" the elements from the Iterator with
list()
it works!Expected Behavior
Should print out
The text was updated successfully, but these errors were encountered: