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 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 Version 0.20.1
============== ==============

View File

@ -1,6 +1,6 @@
[package] [package]
name = "rhai_codegen" name = "rhai_codegen"
version = "0.3.5" version = "0.3.6"
edition = "2018" edition = "2018"
authors = ["jhwgh1968", "Stephen Chung"] authors = ["jhwgh1968", "Stephen Chung"]
description = "Procedural macros support package for Rhai, a scripting language and engine for Rust" 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", "property setter requires exactly 2 parameters",
)) ))
} }
// 3b. Property setters must return nothing. // 3b. Non-raw property setters must return nothing.
FnSpecialAccess::Property(Property::Set(_)) if self.return_type().is_some() => { FnSpecialAccess::Property(Property::Set(_))
if params.return_raw.is_none() && self.return_type().is_some() =>
{
return Err(syn::Error::new( return Err(syn::Error::new(
self.signature.output.span(), self.signature.output.span(),
"property setter cannot return any value", "property setter cannot return any value",
@ -569,8 +571,10 @@ impl ExportedFn {
"index setter requires exactly 3 parameters", "index setter requires exactly 3 parameters",
)) ))
} }
// 5b. Index setters must return nothing. // 5b. Non-raw index setters must return nothing.
FnSpecialAccess::Index(Index::Set) if self.return_type().is_some() => { FnSpecialAccess::Index(Index::Set)
if params.return_raw.is_none() && self.return_type().is_some() =>
{
return Err(syn::Error::new( return Err(syn::Error::new(
self.signature.output.span(), self.signature.output.span(),
"index setter cannot return any value", "index setter cannot return any value",