Get return_value_handling fully working

This commit is contained in:
Jason Turner
2015-04-10 09:32:01 -06:00
parent a3f88b43ce
commit 2e769d81cf
3 changed files with 15 additions and 6 deletions

View File

@@ -558,6 +558,10 @@ namespace chaiscript
throw exception::eval_error("Error with unsupported arithmetic assignment operation");
}
} else if (m_oper == Operators::assign) {
if (lhs.is_return_value()) {
throw exception::eval_error("Error, cannot assign to temporary value.");
}
try {
if (lhs.is_undef()) {
if (!this->children.empty() &&
@@ -567,14 +571,14 @@ namespace chaiscript
/// \todo This does not handle the case of an unassigned reference variable
/// being assigned outside of its declaration
lhs.assign(rhs);
lhs.reset_return_value();
return rhs;
} else {
if (!rhs.is_return_value())
{
rhs = t_ss.call_function("clone", rhs);
} else {
rhs.reset_return_value();
}
rhs.reset_return_value();
}
}