From 3fdaced52fae959eb1a5dc7dacc1abc31fed72a8 Mon Sep 17 00:00:00 2001 From: JoeStrout Date: Wed, 13 Sep 2023 13:01:41 -0700 Subject: [PATCH] Fixed a bug causing map.indexOf to bail out after encountering a null value. --- MiniScript-cs/MiniscriptIntrinsics.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MiniScript-cs/MiniscriptIntrinsics.cs b/MiniScript-cs/MiniscriptIntrinsics.cs index 172580c..31f5a55 100644 --- a/MiniScript-cs/MiniscriptIntrinsics.cs +++ b/MiniScript-cs/MiniscriptIntrinsics.cs @@ -606,11 +606,11 @@ public static void InitIfNeeded() { } else if (self is ValMap) { ValMap map = (ValMap)self; bool sawAfter = (after == null); - foreach (Value k in map.map.Keys) { + foreach (var kv in map.map) { if (!sawAfter) { - if (k.Equality(after) == 1) sawAfter = true; + if (kv.Key.Equality(after) == 1) sawAfter = true; } else { - if (map.map[k].Equality(value) == 1) return new Intrinsic.Result(k); + if (kv.Value == null ? value == null : kv.Value.Equality(value) == 1) return new Intrinsic.Result(kv.Key); } } }