I believe I have found a bug in List.concat (or adjacent code).
While programming the 5th day of advent of code I ended up in a situation where
List.concat a b
and
List.walk b a List.append
were giving me different result, which is nonsense since it is pretty trivial to observe that they are the same.
However, my reproduction is complex, it's 135 lines of code, and I don't really know how to simplify it without the bug disappearing. This also makes me think that maybe the bug is not the actual implementation of concat, but maybe Roc assuming that some shared object is actually unique and can be mutated, or some other optimization. I am not sure of what the best way of reporting this bug would be.
can you put it in a gist? I think it depends a bit on what the code looks like and if the problem is obvious (with e.g. valgrind)
https://gist.github.com/asielorz/a5128af84d254cce9c999c66257f37b7
I hope it helps
hmm, the program fails on the input file for me
is that bit at the top supposed to be there?
Well, yes. Sorry for the bad bug report :sweat_smile:
I have updated it to a new version that does not need an external input file and still has the bug. The code is much shorter and much less noisy, and all file IO has been removed. I hope it helps.
I think this is possibly a similar issue to https://github.com/roc-lang/roc/issues/4697 where I managed to get a somewhat small reproduction. Interesting how many people are running into this considering it's not exactly trivial to reproduce!
allright, I'll have to look in more detail, it's not (clearly, anyway) a memory corruption bug
so it could indeed be an incorrect in-place mutation
thanks for reporting!
I talked to @Ayaz Hafiz about it this morning too though I'm not sure if he was looking into it yet. Thanks Folkert and @Asier Elorz (he/him) !
This should be fixed in tomorrow's nightly release of roc!
Last updated: Jul 26 2025 at 12:14 UTC