Consistently warn about mixing vector and scalar operand depreciaton

Resolves #1890
This commit is contained in:
Zeke 2022-01-19 10:03:41 -08:00
parent becc966106
commit 7ec2fa2ac9
4 changed files with 89 additions and 3 deletions

View file

@ -622,6 +622,14 @@ protected:
void ExprDescribe(ODesc* d) const override;
// Reports on if this BinaryExpr involves a scalar and
// aggregate type (vec, list, table, record).
bool IsScalarAggregateOp() const;
// Warns about depreciated scalar vector operations like
// `[1, 2, 3] == 1` or `["a", "b", "c"] + "a"`.
void CheckScalarAggOp() const;
ExprPtr op1;
ExprPtr op2;
};
@ -1801,5 +1809,15 @@ inline bool is_vector(const ExprPtr& e)
return is_vector(e.get());
}
// True if the given Expr* has a list type
inline bool is_list(Expr* e)
{
return e->GetType()->Tag() == TYPE_LIST;
}
inline bool is_list(const ExprPtr& e)
{
return is_list(e.get());
}
} // namespace detail
} // namespace zeek