From 47095d0d0b302e9e35f71d4f8212d87cea6caf95 Mon Sep 17 00:00:00 2001 From: David Taralla Date: Sat, 3 Oct 2026 17:45:07 -0400 Subject: [PATCH] Fix QueryBuilder.TermAt(int termIndex) Term index was not set *before* checking the type of the current term, leading to misleading asserts. C++ implementation is setting the term first, then asserting, then returning. See mirror C++ implementation: https://www.flecs.dev/flecs/query_2builder__i_8hpp_source.html#l00188 --- src/Flecs.NET/Core/QueryBuilder.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Flecs.NET/Core/QueryBuilder.cs b/src/Flecs.NET/Core/QueryBuilder.cs index 5fc85a41..c141b518 100644 --- a/src/Flecs.NET/Core/QueryBuilder.cs +++ b/src/Flecs.NET/Core/QueryBuilder.cs @@ -1669,8 +1669,9 @@ public ref QueryBuilder TermAt(int termIndex) /// public ref QueryBuilder TermAt(int termIndex) { + ref QueryBuilder @this = ref TermAt(termIndex); Ecs.Assert(Ecs.TypeIdIs(World, CurrentTerm.id) || Ecs.TypeIdIs(World, Ecs.Pair(CurrentTerm.first.id, CurrentTerm.second.id)), "Term type does not match."); - return ref TermAt(termIndex); + return ref @this; } ///