Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/core/exception.d
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class ArrayIndexError : RangeError
this.length = length;

// Constructing the message is a bit clumsy:
// It's essentially `printf("index [%zu] exceeds array of length [%zu]", index, length)`,
// It's essentially `printf("index [%zu] is out of bounds for array of length [%zu]", index, length)`,
// but even `snprintf` isn't `pure`.
// Also string concatenation isn't `@nogc`, and casting to/from immutable isn't `@safe`
import core.internal.string : unsignedToTempString;
Expand All @@ -107,7 +107,7 @@ class ArrayIndexError : RangeError
sink.rangeMsgPut("index [");
sink.rangeMsgPut(unsignedToTempString!10(index, tmpBuf));
sink.rangeMsgPut("]");
sink.rangeMsgPut(" exceeds array of length ");
sink.rangeMsgPut(" is out of bounds for array of length ");
Comment thread
nordlow marked this conversation as resolved.
sink.rangeMsgPut(unsignedToTempString!10(length, tmpBuf));
this.msgBuf = buf;
super(msgBuf[0..$-sink.length], file, line, next);
Expand All @@ -116,7 +116,7 @@ class ArrayIndexError : RangeError

@safe pure unittest
{
assert(new ArrayIndexError(900, 700).msg == "index [900] exceeds array of length 700");
assert(new ArrayIndexError(900, 700).msg == "index [900] is out of bounds for array of length 700");
// Ensure msg buffer doesn't overflow on large numbers
assert(new ArrayIndexError(size_t.max, size_t.max-1).msg);
}
Expand Down