Skip to content

Hitting unreachable arm in on_ready.rs #1350

@nocommentsgood

Description

@nocommentsgood

When using OnReady I'm hitting a match arm with unreachable!(). This occurs when, in the example below, the TestUnreachable struct attempts to get a node in the scene tree using an incorrect path.

I'm still on version 0.3.5.

ERROR: [panic /home/me/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/godot-core-0.3.5/src/obj/on_ready.rs:270]
internal error: entered unreachable code
Context: IDKAnymore::process
at: godot_core::private::set_gdext_hook::{{closure}} (/home/me/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/godot-core-0.3.5/src/private.rs:310)

Reproduction:
Scene with root node of type SomeType. Add a child Timer node (I'm assuming this occurs with any node type).

struct TestUnreachable {
    timer: Gd<Timer>,
}

impl TestUnreachable {
    fn new(some_node: &Gd<Node>) -> Self {
        Self {
            timer: some_node.get_node_as::<Timer>("WrongName"),
        }
    }
}

#[derive(GodotClass)]
#[class(init, base = Node)]
struct SomeType {
    #[init(val = OnReady::from_base_fn(|base| TestUnreachable::new(base)))]
    test: OnReady<TestUnreachable>,
    base: Base<Node>,
}

#[godot_api]
impl INode for SomeType {
    fn process(&mut self, delta: f32) {
        dbg!(&self.test.timer);
    }
}

The first time the program attempts to read/write the value of the timer, it correctly panics with "There is no node of type Timer at path ...". Any subsequent attempts, such as trying to debug it in process() hit the unreachable() arm.

I understand that this should panic, as I am providing the incorrect name of the node, but I'm pretty sure an unreachable arm should not be reachable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions