Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix entity does not exist message on index reuse #17264

Open
wants to merge 9 commits into from

Conversation

SpecificProtagonist
Copy link
Contributor

Objective

With the track_location feature, the error message of trying to acquire an entity that was despawned pointed to the wrong line if the entity index has been reused.

Showcase

use bevy_ecs::prelude::*;

fn main() {
    let mut world = World::new();
    let e = world.spawn_empty().id();
    world.despawn(e);
    world.flush();
    let _ = world.spawn_empty();
    world.entity(e);
}

Old message:

Entity 0v1 was despawned by src/main.rs:8:19

New message:

Entity 0v1 does not exist (its index has been reused)

@SpecificProtagonist SpecificProtagonist added C-Bug An unexpected or incorrect behavior A-ECS Entities, components, systems, and events D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 9, 2025
crates/bevy_ecs/Cargo.toml Outdated Show resolved Hide resolved
@alice-i-cecile alice-i-cecile added this to the 0.16 milestone Jan 10, 2025
Copy link
Contributor

@chescock chescock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I left some style suggestions, but nothing blocking.

The test doesn't get run by CI, right? Maybe we should create an issue to run tests with the track_location feature enabled. This probably won't be the last time we want tests for it!

crates/bevy_ecs/src/entity/mod.rs Outdated Show resolved Hide resolved
crates/bevy_ecs/src/entity/mod.rs Outdated Show resolved Hide resolved
@BenjaminBrienen BenjaminBrienen added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 11, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants