Skip to content

Editorial: use the exclusive range where the range can be empty - #1632

Merged
Ms2ger merged 1 commit into
mainfrom
range-exclusive
Aug 31, 2026
Merged

Editorial: use the exclusive range where the range can be empty#1632
Ms2ger merged 1 commit into
mainfrom
range-exclusive

Conversation

@annevk

@annevk annevk commented Aug 30, 2026

Copy link
Copy Markdown
Member

Several algorithms iterated with "the range 0 to X − 1, inclusive", which is a decreasing range when X is 0. Infra only defines "the range n to m, inclusive" for m greater than or equal to n, so those cases were not well-defined, even though the empty ordered set was clearly what was intended — see for instance the note about i being 0 in the overload set construction.

Switch to "the range n to m, exclusive", which Infra already defines to create an empty ordered set when m equals n. This needs no Infra change.

Sites changed:

  • "create an overload set": |n| to |max|, 0 to |n|, and 0 to |i|. The remaining |n| to |i|, inclusive is left alone, since |i| is always greater than or equal to |n| there.
  • "get a copy of the bytes held by the buffer source", which was decreasing for a zero-length buffer source.
  • "write into an ArrayBuffer", which was decreasing for an empty byte sequence.

Several algorithms iterated with "the range 0 to X - 1, inclusive", which is a
decreasing range when X is 0. Infra only defines "the range n to m, inclusive"
for m greater than or equal to n, so those cases were not well-defined, even
though the empty ordered set was clearly what was intended -- see for instance
the note about |i| being 0 in the overload set construction.

Switch to "the range n to m, exclusive", which Infra defines to create an empty
ordered set when m equals n. The range in "for each |j| in the range |n| to |i|,
inclusive" is left alone, since |i| is always greater than or equal to |n| there.
@annevk
annevk requested review from Ms2ger and saschanaz August 30, 2026 14:11
@Ms2ger
Ms2ger merged commit 8f18262 into main Aug 31, 2026
2 checks passed
@Ms2ger
Ms2ger deleted the range-exclusive branch August 31, 2026 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants