From 58d55d0f951894984c22dfdbc0a2fb7dd676fb94 Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Mon, 13 May 2019 20:02:59 -0700 Subject: [PATCH] GH-365: improve un-indexable type error message --- CHANGES | 4 ++++ VERSION | 2 +- src/Expr.cc | 7 ++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index c4d2d26a68..44d8cf4c93 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,8 @@ +2.6-279 | 2019-05-13 20:02:59 -0700 + + * GH-365: improve un-indexable type error message (Jon Siwek, Corelight) + 2.6-277 | 2019-05-08 12:42:18 -0700 * Allow tuning Broker log batching via scripts (Jon Siwek, Corelight) diff --git a/VERSION b/VERSION index 64298b5057..1268552eaf 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.6-277 +2.6-279 diff --git a/src/Expr.cc b/src/Expr.cc index e6cb9937c4..efbd96f04f 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -2917,7 +2917,12 @@ IndexExpr::IndexExpr(Expr* arg_op1, ListExpr* arg_op2, bool is_slice) int match_type = op1->Type()->MatchesIndex(arg_op2); if ( match_type == DOES_NOT_MATCH_INDEX ) - SetError("not an index type"); + { + std::string error_msg = + fmt("expression with type '%s' is not a type that can be indexed", + type_name(op1->Type()->Tag())); + SetError(error_msg.data()); + } else if ( ! op1->Type()->YieldType() ) {