Fix unhandled cases of casting to array & function types

This commit is contained in:
Nikita Lisitsa 2025-12-18 17:03:59 +03:00
parent 2f5ad00b6d
commit 9826961c76

View file

@ -472,6 +472,18 @@ namespace pslang::interpreter
return std::visit([&](auto const & type){ return cast_impl(value, type); }, type);
}
template <typename T>
value cast_impl(primitive_value_base<T> const &, type::array_type const &)
{
throw std::runtime_error("Cannot cast anything to array type");
}
template <typename T>
value cast_impl(primitive_value_base<T> const &, type::function_type const &)
{
throw std::runtime_error("Cannot cast anything to function type");
}
template <typename T>
value cast_impl(primitive_value_base<T> const & value, type::type const & type)
{