Skip to content

Commit

Permalink
fix: panic if plugin_fn applied to main fn (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
nilslice authored Dec 14, 2022
1 parent 1458d41 commit ec173ad
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ pub fn plugin_fn(
panic!("extism_pdk::plugin_fn expects a function with one argument, `()` may be used if no input is needed");
}

if name == "main" {
panic!(
"extism_pdk::plugin_fn must not be applied to a `main` function. To fix, rename this to something other than `main`."
)
}

match output {
syn::ReturnType::Default => panic!(
"extism_pdk::plugin_fn expects a return value, `()` may be used if no output is needed"
Expand Down

0 comments on commit ec173ad

Please sign in to comment.