SanderMertens / flecs

A fast entity component system (ECS) for C & C++

Home Page:https://www.flecs.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Queries with Or terms and wildcard terms cause internal error

nimble0 opened this issue · comments

Describe the bug
Certain combinations of Or terms and wildcard terms trigger an internal error assert.

To Reproduce

#include <basics.h>
#include <iostream>

struct Position { 
	double x, y;
};

int main(int, char *[]) {
	flecs::world ecs;

	auto tag1 = ecs.entity("tag1");
	auto tag2 = ecs.entity("tag2");
	auto tag3 = ecs.entity("tag3");
	auto tag4 = ecs.entity("tag4");

	ecs.entity("e1")
		.add(tag1)
		.set(tag3, Position{10, 20})
		.set(tag4, Position{10, 20});

	ecs.filter_builder()
		.term(tag1)
		.or_().term(tag2)
		.term().first<Position>().second(flecs::Wildcard).in()
		.build()
		.iter([](flecs::iter& iter)
		{
			for(auto i : iter)
				std::cout<<iter.entity(i)<<"\n";
		});
}

Result
fatal: filter.c: 3205: assert: i >= 0 INTERNAL_ERROR

Additional context
This started with 0ec4e06

Fixed!