Allow setters returning values when return_raw.

This commit is contained in:
Stephen Chung 2021-05-02 23:51:37 +08:00
parent 9fabca5937
commit 13d5092c4d
3 changed files with 15 additions and 5 deletions

View File

@ -4,6 +4,12 @@ Rhai Release Notes
Version 0.20.2
==============
New features
------------
* Each `Dynamic` value can now contain arbitrary data (type `i16`) in the form of a _tag_. This is to use up otherwise wasted space in the `Dynamic` type.
Version 0.20.1
==============

View File

@ -1,6 +1,6 @@
[package]
name = "rhai_codegen"
version = "0.3.5"
version = "0.3.6"
edition = "2018"
authors = ["jhwgh1968", "Stephen Chung"]
description = "Procedural macros support package for Rhai, a scripting language and engine for Rust"

View File

@ -541,8 +541,10 @@ impl ExportedFn {
"property setter requires exactly 2 parameters",
))
}
// 3b. Property setters must return nothing.
FnSpecialAccess::Property(Property::Set(_)) if self.return_type().is_some() => {
// 3b. Non-raw property setters must return nothing.
FnSpecialAccess::Property(Property::Set(_))
if params.return_raw.is_none() && self.return_type().is_some() =>
{
return Err(syn::Error::new(
self.signature.output.span(),
"property setter cannot return any value",
@ -569,8 +571,10 @@ impl ExportedFn {
"index setter requires exactly 3 parameters",
))
}
// 5b. Index setters must return nothing.
FnSpecialAccess::Index(Index::Set) if self.return_type().is_some() => {
// 5b. Non-raw index setters must return nothing.
FnSpecialAccess::Index(Index::Set)
if params.return_raw.is_none() && self.return_type().is_some() =>
{
return Err(syn::Error::new(
self.signature.output.span(),
"index setter cannot return any value",