-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorD-UnsafeTouches with unsafe code in some wayTouches with unsafe code in some wayP-UnsoundA bug that results in undefined compiler behaviorA bug that results in undefined compiler behaviorS-Needs-InvestigationThis issue requires detective work to figure out what's going wrongThis issue requires detective work to figure out what's going wrong
Description
Bevy version
0.13.2
What you did
I'm noticing some weird behavior with AnyOf.
Given two systems test1 and test2:
#[derive(Component)]
struct X(usize);
// Runs on startup
fn setup_test(mut commands: Commands) {
commands.spawn(X(0));
}
fn test1(query: Query<(&mut X, &mut X)>) {}
fn test2(mut query: Query<AnyOf<(&mut X, &mut X)>>) {
let (a, b) = query.single_mut();
a.unwrap().0 += 1;
*b.unwrap() = X(3);
let (a, _) = query.single();
dbg!(a.unwrap().0);
}Obviously test1 fails to run, since Query<(&mut X, &mut X)> is invalid.
But somehow test2 is perfectly ok. I was expecting at least one of a or b to be None, but nope! Both a and b are valid, implying we can violate the single mutable alias rule with AnyOf.
Running an app with test2 prints "3", always, which seems like an error.
andriyDev, Gingeh, orzogc and janhohenheim
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorD-UnsafeTouches with unsafe code in some wayTouches with unsafe code in some wayP-UnsoundA bug that results in undefined compiler behaviorA bug that results in undefined compiler behaviorS-Needs-InvestigationThis issue requires detective work to figure out what's going wrongThis issue requires detective work to figure out what's going wrong