Skip to content
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

Rewrite rules for Lazy.compareLength are too lazy #507

Open
clyring opened this issue Apr 3, 2022 · 3 comments
Open

Rewrite rules for Lazy.compareLength are too lazy #507

clyring opened this issue Apr 3, 2022 · 3 comments

Comments

@clyring
Copy link
Member

clyring commented Apr 3, 2022

Lazy.length s must force the entirety of s, while (by design) Lazy.compareLength s 10 stops after finding at least 11 words. And yet we try to rewrite Lazy.length s > 10 to Lazy.compareLength s 10 == GT. I can't quickly think of any "reasonable-looking" example where this change will actually cause problems, but I am deeply skeptical of a rewrite rule that silently changes strictness behavior in this way, especially since it is common for forcing a lazy bytestring to mean performing deferred I/O actions.

(Also, Int64 overflow can happen in Lazy.length but not in Lazy.compareLength, though it's probably only possible to actually observe that difference in behavior by doing something rather stupid.)

@sjakobi
Copy link
Member

sjakobi commented Apr 3, 2022

Let's document that length may get rewritten to compareLength and may not force the entire string.

@clyring clyring added this to the 0.12.0.0 milestone Jan 15, 2023
@Bodigrim
Copy link
Contributor

My vote is for wontfix and documentation.

@clyring
Copy link
Member Author

clyring commented Jun 13, 2023

I still prefer killing the rules, but it's not a battle worth fighting. And if we aren't removing these rules then I don't consider this important for 0.12.0.

@clyring clyring removed this from the 0.12.0.0 milestone Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants