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

void-returning non-throwing async method generates broken binding code #1477

Open
kawadakk opened this issue Jun 21, 2023 · 1 comment
Open

Comments

@kawadakk
Copy link
Contributor

Given a Vala interface method:

public virtual async void hoge_async() {}

gir generates the following trampoline:

unsafe extern "C" fn hoge_async_trampoline<P: FnOnce(()) + 'static>(_source_object: *mut glib::gobject_ffi::GObject, res: *mut gio::ffi::GAsyncResult, user_data: glib::ffi::gpointer) {
    let _ = ffi::foo_bar_hoge_finish(_source_object as *mut _, res);
    let callback: Box_<glib::thread_guard::ThreadGuard<P>> = Box_::from_raw(user_data as *mut _);
    let callback: P = callback.into_inner();
    callback(result); // error[E0425]: cannot find value `result` in this scope
}
@kawadakk
Copy link
Contributor Author

This is where the problematic line is generated:

body.push(Chunk::Call {
func_name: "callback".to_string(),
arguments: vec![Chunk::Name("result".to_string())],
});

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