From 7237e4a03af59016c8b202fae0e119390e46cb82 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Tue, 9 Dec 2025 11:55:15 +0100 Subject: [PATCH] std.variant: Fix deprecation in VariantN.opApply() 'Deprecation: cannot return non-zero compile-time value from `opApply`' Hit e.g. when compiling the unittests. --- std/variant.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/std/variant.d b/std/variant.d index a094aeb3409..b76b172521e 100644 --- a/std/variant.d +++ b/std/variant.d @@ -1207,7 +1207,7 @@ public: auto arr = get!(A[]); foreach (ref e; arr) { - if (dg(e)) return 1; + if (auto r = dg(e)) return r; } } else static if (is(A == VariantN)) @@ -1219,7 +1219,7 @@ public: // Variant when in fact they are only changing tmp. auto tmp = this[i]; debug scope(exit) assert(tmp == this[i]); - if (dg(tmp)) return 1; + if (auto r = dg(tmp)) return r; } } else