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

Nondescriptive panic message during resource_scope #5365

Closed
jakobhellermann opened this issue Jul 18, 2022 · 0 comments
Closed

Nondescriptive panic message during resource_scope #5365

jakobhellermann opened this issue Jul 18, 2022 · 0 comments
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior D-Trivial Nice and easy! A great choice to get started with Bevy

Comments

@jakobhellermann
Copy link
Contributor

Bevy version

bevy main

What you did

When inserting the resource removed in resource_scope during the callback

use bevy_ecs::prelude::*;

struct Resource {}

fn main() {
    let mut world = World::new();
    world.insert_resource(Resource {});
    world.resource_scope(|world, _res: Mut<Resource>| {
        world.insert_resource(Resource {});
    });
}

bevy panics with an unhelpful message of

thread 'main' panicked at 'assertion failed: !self.contains_resource::<R>()', /home/jakob/.cargo/registry/src/index.crates.io-e139d0d48fed7772/bevy_ecs-0.7.0/src/world/mod.rs:1072:9

What went wrong

It would be nice to show more information, something like resource repro::Resource was inserted during call to resource_scope, which is not allowed because ....

@jakobhellermann jakobhellermann added C-Bug An unexpected or incorrect behavior D-Trivial Nice and easy! A great choice to get started with Bevy A-ECS Entities, components, systems, and events labels Jul 18, 2022
@bors bors bot closed this as completed in 00323b3 Aug 18, 2022
maccesch pushed a commit to Synphonyte/bevy that referenced this issue Sep 28, 2022
# Objective

- Fixes bevyengine#5365 
- The `assert!()` when the resource from `World::resource_scope` is inserted into the world is not descriptive.

## Solution

- Add more context to the assert inside of `World::resource_scope` when the `FnOnce` param inserts the resource.
james7132 pushed a commit to james7132/bevy that referenced this issue Oct 28, 2022
# Objective

- Fixes bevyengine#5365 
- The `assert!()` when the resource from `World::resource_scope` is inserted into the world is not descriptive.

## Solution

- Add more context to the assert inside of `World::resource_scope` when the `FnOnce` param inserts the resource.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
# Objective

- Fixes bevyengine#5365 
- The `assert!()` when the resource from `World::resource_scope` is inserted into the world is not descriptive.

## Solution

- Add more context to the assert inside of `World::resource_scope` when the `FnOnce` param inserts the resource.
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-Trivial Nice and easy! A great choice to get started with Bevy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant