Merge remote-tracking branch 'origin/topic/zeke/gh-1890'

* origin/topic/zeke/gh-1890:
  Consistently warn about mixing vector and scalar operand depreciaton
This commit is contained in:
Robin Sommer 2022-02-02 09:46:00 +01:00
commit 5b1691f162
No known key found for this signature in database
GPG key ID: 6BEDA4DA6B8B23E3
4 changed files with 90 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,16 @@ 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