#[rhai_fn(pure)] must have &mut parameter.
This commit is contained in:
parent
d935401b03
commit
823ecef1f1
@ -503,10 +503,9 @@ impl ExportedFn {
|
||||
}
|
||||
|
||||
pub fn set_params(&mut self, mut params: ExportedFnParams) -> syn::Result<()> {
|
||||
// Several issues are checked here to avoid issues with diagnostics caused by raising them
|
||||
// later.
|
||||
// Several issues are checked here to avoid issues with diagnostics caused by raising them later.
|
||||
//
|
||||
// 1. Do not allow non-returning raw functions.
|
||||
// 1a. Do not allow non-returning raw functions.
|
||||
//
|
||||
if params.return_raw && self.return_type().is_none() {
|
||||
return Err(syn::Error::new(
|
||||
@ -515,6 +514,15 @@ impl ExportedFn {
|
||||
));
|
||||
}
|
||||
|
||||
// 1b. Do not allow non-method pure functions.
|
||||
//
|
||||
if params.pure && !self.mutable_receiver() {
|
||||
return Err(syn::Error::new(
|
||||
self.signature.span(),
|
||||
"functions marked with 'pure' must have a &mut first parameter",
|
||||
));
|
||||
}
|
||||
|
||||
match params.special {
|
||||
// 2a. Property getters must take only the subject as an argument.
|
||||
FnSpecialAccess::Property(Property::Get(_)) if self.arg_count() != 1 => {
|
||||
|
Loading…
Reference in New Issue
Block a user