Ensure that non-shared_ptr, non-boxed_value, non-reference return types
are treated as const.
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
namespace chaiscript
|
namespace chaiscript
|
||||||
{
|
{
|
||||||
|
/// \internal
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
namespace threading
|
namespace threading
|
||||||
|
@@ -27,7 +27,7 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
static Boxed_Value handle(const Ret &r)
|
static Boxed_Value handle(const Ret &r)
|
||||||
{
|
{
|
||||||
return Boxed_Value(r);
|
return const_var(r);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -40,6 +40,15 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename Ret>
|
||||||
|
struct Handle_Return<boost::shared_ptr<Ret> >
|
||||||
|
{
|
||||||
|
static Boxed_Value handle(const boost::shared_ptr<Ret> &r)
|
||||||
|
{
|
||||||
|
return Boxed_Value(r);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template<typename Ret>
|
template<typename Ret>
|
||||||
struct Handle_Return<const boost::shared_ptr<Ret> &>
|
struct Handle_Return<const boost::shared_ptr<Ret> &>
|
||||||
{
|
{
|
||||||
@@ -88,6 +97,18 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used internally for handling a return value from a Proxy_Function call
|
||||||
|
*/
|
||||||
|
template<>
|
||||||
|
struct Handle_Return<const Boxed_Value>
|
||||||
|
{
|
||||||
|
static Boxed_Value handle(const Boxed_Value &r)
|
||||||
|
{
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used internally for handling a return value from a Proxy_Function call
|
* Used internally for handling a return value from a Proxy_Function call
|
||||||
*/
|
*/
|
||||||
|
2
unittests/assign_const.chai
Normal file
2
unittests/assign_const.chai
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
assert_throws("Mismatched types in equation, lhs is const.", fun() { 1 = 2 } );
|
||||||
|
assert_throws("Mismatched types in equation, lhs is const.", fun() { 1 + 2 = 2 } );
|
Reference in New Issue
Block a user