From 99c812fc6b2e8d53b178b3016ec38218bd30a6d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Nordl=C3=B6w?= Date: Thu, 9 Dec 2021 13:56:07 +0100 Subject: [PATCH] Use onRangeError in StringMap.opIndex --- source/mir/string_map.d | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/mir/string_map.d b/source/mir/string_map.d index 4331f4fd..b0cbdb71 100644 --- a/source/mir/string_map.d +++ b/source/mir/string_map.d @@ -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)) @@ -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))