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

Box<dyn Reflect> struct with a hashmap in it panics when clone_value is called on it #8183

Closed
NoahShomette opened this issue Mar 23, 2023 · 0 comments · Fixed by #8184
Closed
Labels
A-Reflection Runtime information about types C-Bug An unexpected or incorrect behavior
Milestone

Comments

@NoahShomette
Copy link
Contributor

NoahShomette commented Mar 23, 2023

Bevy version

0.10.0 and main

What you did

Create a struct that has a HashMap in it with two different structs for the Key and Value in it. Box the struct with a hashmap into a Box. Call clone_value() on the new boxed struct.

Minimal reproduction here:

fn test_system(){
    let mut hashmap_thing = HashMapThing::default();
    hashmap_thing.hashmap.insert(Key::default(), Value::default());
    
    let reflected_value = Box::new(hashmap_thing) as Box<dyn Reflect>;
    
    let cloned_value = reflected_value.clone_value();
    println!("{:?}", cloned_value);
}

#[derive(Debug, Default, Reflect, FromReflect)]
struct HashMapThing{
    pub hashmap: HashMap<Key, Value>
}

#[derive(Debug,Eq, PartialEq, Hash, Default, Reflect, FromReflect)]
#[reflect(Hash)]
struct Key;

#[derive(Debug,Default, Reflect, FromReflect)]
struct Value;

What went wrong

This will crash when it attempts to clone_value() with the error: "The given key does not support hashing"

@NoahShomette NoahShomette added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Mar 23, 2023
@MrGVSV MrGVSV added A-Reflection Runtime information about types and removed S-Needs-Triage This issue needs to be labelled labels Mar 23, 2023
@MrGVSV MrGVSV added this to the 0.10.1 milestone Mar 23, 2023
@cart cart modified the milestones: 0.10.1, 0.11 Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Reflection Runtime information about types C-Bug An unexpected or incorrect behavior
Projects
Status: Done
3 participants