diff --git a/crates/bevy_ecs/src/query/fetch.rs b/crates/bevy_ecs/src/query/fetch.rs index 2700fe3ac4..08bcbbe27b 100644 --- a/crates/bevy_ecs/src/query/fetch.rs +++ b/crates/bevy_ecs/src/query/fetch.rs @@ -1864,16 +1864,13 @@ macro_rules! impl_anytuple_fetch { fn update_component_access(state: &Self::State, _access: &mut FilteredAccess) { let mut _new_access = _access.clone(); - // update the access (add the read/writes) - <($(Option<$name>,)*)>::update_component_access(state, _access); - // update the filters (Or<(With<$name>,)>) let ($($name,)*) = state; let mut _not_first = false; $( if _not_first { - // we use an intermediate access because we only want to update the filters, not the access - let mut intermediate = FilteredAccess::default(); + // we use an intermediate access because we only want to update the filter_sets, not the access + let mut intermediate = _access.clone(); $name::update_component_access($name, &mut intermediate); _new_access.append_or(&intermediate); } else { @@ -1884,6 +1881,11 @@ macro_rules! impl_anytuple_fetch { )* _access.filter_sets = _new_access.filter_sets; + + // update the access (add the read/writes) + // Option updates the access but not the filter_sets + <($(Option<$name>,)*)>::update_component_access(state, _access); + } #[allow(unused_variables)] fn init_state(world: &mut World) -> Self::State { diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index 9ae9f2587d..d2cf03a96e 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -563,6 +563,13 @@ mod tests { run_system(&mut world, sys); } + #[test] + fn any_of_with_and_without_common() { + fn sys(_: Query<(&mut D, &C, AnyOf<(&A, &B)>)>, _: Query<&mut D, Without>) {} + let mut world = World::default(); + run_system(&mut world, sys); + } + #[test] #[should_panic = "&bevy_ecs::system::tests::A conflicts with a previous access in this query."] fn any_of_with_mut_and_ref() {