Skip to content

Commit

Permalink
ivy: simplify an error message for a bad index
Browse files Browse the repository at this point in the history
It repeated too much, and without the repetition is no less clear.
  • Loading branch information
robpike committed Jan 8, 2025
1 parent e1b2cb8 commit b4f3aa6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion testdata/exec_fail.ivy
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ x
(log 2)[1]
#

# Expect: invalid index (2) (float) in 1 2 (float 2) in (1 2)[1 2 (float 2)]
# Expect: invalid index (2) (type float) in (1 2)[1 2 (float 2)]
1 2[1 2 (float 2)]
#

Expand Down
4 changes: 2 additions & 2 deletions value/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (ix *indexState) init(context Context, top, left Expr, index []Expr) {
x := index[i].Eval(context).Inner()
switch x := x.(type) {
default:
Errorf("invalid index %s (%s) in %s", index[i].ProgString(), whichType(x), top.ProgString())
Errorf("invalid index %s (type %s) in %s", index[i].ProgString(), whichType(x), top.ProgString())
case Int:
ix.indexes[i] = NewVector([]Value{x})
case *Vector:
Expand All @@ -59,7 +59,7 @@ func (ix *indexState) init(context Context, top, left Expr, index []Expr) {
}
for _, v := range ix.indexes[i].All() {
if _, ok := v.(Int); !ok {
Errorf("invalid index %s (%s) in %s in %s", v, whichType(v), index[i].ProgString(), top.ProgString())
Errorf("invalid index %s (type %s) in %s", v, whichType(v), top.ProgString())
}
}
}
Expand Down

0 comments on commit b4f3aa6

Please sign in to comment.