Skip to content

Commit

Permalink
Use onRangeError in StringMap.opIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
nordlow committed Dec 9, 2021
1 parent b21ff32 commit 99c812f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions source/mir/string_map.d
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ struct StringMap(T, U = uint)
/++
Complexity: `O(log(s))`, where `s` is the number of the keys with the same length as the input key.
+/
ref inout(T) opIndex()(scope const(char)[] key) @trusted pure inout //@nogc
ref inout(T) opIndex()(scope const(char)[] key) @trusted pure inout nothrow @nogc
{
size_t index;
if (implementation && implementation.findIndex(key, index))
Expand All @@ -542,8 +542,9 @@ struct StringMap(T, U = uint)
assert (index < length);
return implementation._values[index];
}
import mir.exception: MirException;
throw new MirException("No member: ", key);
import core.exception : onRangeError;
onRangeError();
return implementation._values[0]; // TODO: remove when onRangeError is noreturn
}

version(mir_test) static if (is(T == int))
Expand Down

0 comments on commit 99c812f

Please sign in to comment.