Constrained the element’s type in set element expressions to primitive terms.

This commit is contained in:
2017-03-29 23:56:58 +02:00
parent dbb106c40b
commit 3c79625685
2 changed files with 12 additions and 11 deletions

View File

@@ -14,6 +14,12 @@ namespace ast
//
////////////////////////////////////////////////////////////////////////////////////////////////////
// Terms are primitive (or arguments) if they are neither operations nor intervals
inline bool isPrimitive(const ast::Term &term)
{
return (!term.is<ast::BinaryOperation>() && !term.is<ast::Interval>());
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Primitives
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -112,12 +118,15 @@ struct Function
////////////////////////////////////////////////////////////////////////////////////////////////////
// TODO: refactor (limit element type to primitive terms)
struct In
{
In(Term &&element, Term &&set)
: element{std::move(element)},
set{std::move(set)}
{
// While the set may be any term, the element must be primitive
assert(isPrimitive(element));
}
Term element;