Fix table.move usage in query_cached (#173)
Some checks failed
Analysis / Run Luau Analyze (push) Has been cancelled
Deploy VitePress site to Pages / build (push) Has been cancelled
Publish to NPM / publish (push) Has been cancelled
Unit Testing / Run Luau Tests (push) Has been cancelled
Deploy VitePress site to Pages / Deploy (push) Has been cancelled

* Fix table.move usage in query_cached

* Add test case
This commit is contained in:
vnnh 2025-01-04 23:41:52 -06:00 committed by GitHub
parent aafafc90b2
commit 509048b9df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View file

@ -1589,7 +1589,7 @@ local function query_cached(query: QueryInner)
local with = query.filter_with
local ids = query.ids
if with then
table.move(ids, 1, #ids, #with, with)
table.move(ids, 1, #ids, #with + 1, with)
else
query.filter_with = ids
end

View file

@ -1495,5 +1495,22 @@ TEST("repro", function()
end
CHECK(counter == 1)
end
do CASE "#3" -- ISSUE #171
local world = world_new()
local component1 = world:component()
local tag1 = world:entity()
local query = world:query(component1):with(tag1):cached()
local entity = world:entity()
world:set(entity, component1, "some data")
local counter = 0
for x in query:iter() do
counter += 1
end
CHECK(counter == 0)
end
end)
FINISH()