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

@ -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() )
{