Fixed a bug that crashed resolveQuery on complex patterns