Closed BlobCodes closed 1 month ago
I'm wondering if this is intentionally holding up some invariant like it will never consume more bytes from stream2
than from stream1
. But that really doesn't make any sense. We cannot make any assumptions to the state of either stream after same_content?
has return. Except that only if both streams have exactly identical content, both must be at EOF.
So this is clearly missed and should be fixed.
Bug Report
In the following code, the two given IOs are reportedly equal, even though their content is different:
This seems to be because
same_content?
instantly returnstrue
oncestream1
reached EOF: https://github.com/crystal-lang/crystal/blob/4cea10199d5006000a129413f6f607697185c83a/src/io.cr#L1226This probably wasn't noticed because the specs don't compare differently-sized IOs at all.
The crystal compiler also uses this method internally, so as an example, it's easy to corrupt the cache:
NOTE: This won't realistically happen under normal circumstances.