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

Panic in function returning its only argument #654

Open
Snarpix opened this issue Dec 6, 2019 · 0 comments
Open

Panic in function returning its only argument #654

Snarpix opened this issue Dec 6, 2019 · 0 comments

Comments

@Snarpix
Copy link

Snarpix commented Dec 6, 2019

I have experienced panic in dyon 0.44.0 in following code:

use std::sync::Arc;
use dyon::{load_str, error, Call, Module, Runtime, RustObject};

#[derive(Debug)]
struct Test{}

fn main() {
    let mut module = Module::new();
    error(load_str("main.dyon", Arc::new(r#"
        fn test_func(obj: 'return) -> {
            return obj
        }
    "#.into()), &mut module));
    let ref module = Arc::new(module);

    let j = Test{};

    // Call function that returns Rust object.
    let call = Call::new("test_func").rust(j);
    match call.run_ret::<RustObject>(&mut Runtime::new(), module) {
        Ok(answer) => {println!("{:?}", answer.lock().unwrap().downcast_ref::<Test>());}
        Err(err) => {error(Err(err));}
    }
}

thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 1', dyon-0.44.0/src/runtime/mod.rs:108:32

It may be related to comment in runtime/mod.rs:1371

            // TODO: Could return the last value on the stack.
            //       Requires .pop_fn delayed after.

Is this a bug, or am I doing something wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant