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

Can not use vm_result on function taking &mut self #752

Open
VorpalBlade opened this issue Jul 20, 2024 · 0 comments
Open

Can not use vm_result on function taking &mut self #752

VorpalBlade opened this issue Jul 20, 2024 · 0 comments

Comments

@VorpalBlade
Copy link
Contributor

VorpalBlade commented Jul 20, 2024

The following function:

    #[rune::function(vm_result, instance)]
    fn stdin(&mut self) -> Option<ChildStdin> {
        let inner = match &mut self.inner {
            Some(inner) => inner,
            None => {
                rune::vm_panic!("already completed");
            }
        };
        let stdin = inner.stdin.take()?;
        Some(ChildStdin { inner: stdin })
    }

gives the following error:

error[E0308]: mismatched types
   --> crates/konfigkoll_script/src/plugins/process.rs:176:17
    |
176 |                 rune::vm_panic!("already completed");
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Option<ChildStdout>`, found `VmResult<_>`
    |
    = note: expected enum `std::option::Option<plugins::process::ChildStdout>`
               found enum `VmResult<_>`
    = note: this error originates in the macro `rune::vm_panic` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
   --> crates/konfigkoll_script/src/plugins/process.rs:191:17
    |
191 |                 rune::vm_panic!("already completed");
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Option<ChildStderr>`, found `VmResult<_>`
    |
    = note: expected enum `std::option::Option<plugins::process::ChildStderr>`
               found enum `VmResult<_>`
    = note: this error originates in the macro `rune::vm_panic` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0308`.
error: could not compile `konfigkoll_script` (lib) due to 4 previous errors

Removing the vm_result and the vm_panic makes it compile.

This is the latest on the 0.13 branch

@VorpalBlade VorpalBlade changed the title Can not use vm_result on function taking Can not use vm_result on function taking &mut self Jul 20, 2024
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