GH-365: improve un-indexable type error message

This commit is contained in:
Jon Siwek 2019-05-13 20:02:59 -07:00
parent aced89ac9e
commit 58d55d0f95
3 changed files with 11 additions and 2 deletions

View file

@ -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 2.6-277 | 2019-05-08 12:42:18 -0700
* Allow tuning Broker log batching via scripts (Jon Siwek, Corelight) * Allow tuning Broker log batching via scripts (Jon Siwek, Corelight)

View file

@ -1 +1 @@
2.6-277 2.6-279

View file

@ -2917,7 +2917,12 @@ IndexExpr::IndexExpr(Expr* arg_op1, ListExpr* arg_op2, bool is_slice)
int match_type = op1->Type()->MatchesIndex(arg_op2); int match_type = op1->Type()->MatchesIndex(arg_op2);
if ( match_type == DOES_NOT_MATCH_INDEX ) 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() ) else if ( ! op1->Type()->YieldType() )
{ {