From 13d5092c4d9f62ba807f5a5e54dea10148c5498d Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Sun, 2 May 2021 23:51:37 +0800 Subject: [PATCH] Allow setters returning values when return_raw. --- CHANGELOG.md | 6 ++++++ codegen/Cargo.toml | 2 +- codegen/src/function.rs | 12 ++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb98f4e2..cccf5f07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ============== diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml index 778a70fe..284644a8 100644 --- a/codegen/Cargo.toml +++ b/codegen/Cargo.toml @@ -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" diff --git a/codegen/src/function.rs b/codegen/src/function.rs index c8c336e6..1d3029cf 100644 --- a/codegen/src/function.rs +++ b/codegen/src/function.rs @@ -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",