-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Confusing error message in fs.utils #32871
Comments
I think the check should be |
I think, that check is correct. Problem in text of error message. I do not want to open PR myself, because I do not know correct solution. It can be:
|
@force-net The check is incorrect, passing |
I really do not know what is correct behavior. There are some special checks for empty buffer and Line 506 in f22a9ca
Also, in this situation there are no problem to use any offset with zero length. E.g. But for arrays correct range from zero to length - 1, so it logically incorrect to use array index equal to length. May be this condition should be removed completely and full check should be rewrote to:
|
Yeah, thanks for pointing out that the
I don’t think that’s necessarily a bad thing – as you say,
That’s the range for valid indices that can be accessed, not the range for valid offsets, though. Generally, you can take a zero-length slice of an array at its end without that being an error, that’s the most consistent behavior.
That sounds good to me, yes 👍 |
If @force-net is not interested in opening a PR, should I open a PR for the discussed changes? |
@daemon1024 👍 I'm not sure that I can do it in immediate time. It would be fine, if you can do this. |
Great @force-net . @addaleax can I start working in this? |
@daemon1024 Sury, why not :) |
@addaleax can you please review my PR? |
node/lib/internal/fs/utils.js
Line 543 in f22a9ca
This check can produce confusing error message when
offse
t is equal tobufferLength
. Which is error, but message shows, that it is correct (<=)The text was updated successfully, but these errors were encountered: