Skip to content

Queries: Added<Foo> in filter position conflicts with &mut Foo in query position #4624

@nicopap

Description

@nicopap

Bevy version

  • 0.6
  • 0.7

Code

use bevy::prelude::*;

#[derive(Component)]
struct A;
#[derive(Component)]
struct B;
fn main() {
    App::new().add_system(hello_world_system).run();
}

fn hello_world_system(aaas: Query<&A, Added<B>>, bees: Query<&mut B>) {
    println!("hello world");
}

What should happen

cargo run this should print "hello world". As I never access B in aaas, there should be no conflict between bees and aaas.

What happened instead

thread 'main' panicked at 'error[B0001]: Query<&mut bevy_exclusion_bug::B, ()> in system bevy_exclusion_bug::hello_world_system accesses component(s) bevy_exclusion_bug::B in a way that conflicts with a previous system parameter. Consider using `Without<T>` to create disjoint Queries or merging conflicting Queries into a `ParamSet`.', /home/gibonus/.local/share/cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.7.0/src/system/system_param.rs:173:5

Additional information

Initially found out by @linkmauve in nicopap/ui-navigation#21. I'm fairly certain the example worked at one point without crashing. I'll investigate further and report here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions