Skip to content

Commit

Permalink
Merge branch 'delete-non-indexed-expression'
Browse files Browse the repository at this point in the history
  • Loading branch information
jaqx0r committed Dec 17, 2019
2 parents a498e09 + 8ce3d47 commit d609012
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/vm/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,8 +612,11 @@ func (c *checker) VisitAfter(node ast.Node) ast.Node {
return n

case *ast.DelStmt:
n.N.(*ast.IndexedExpr).Lhs.(*ast.IdTerm).Lvalue = true
return n
if ix, ok := n.N.(*ast.IndexedExpr); ok {
ix.Lhs.(*ast.IdTerm).Lvalue = true
return n
}
c.errors.Add(n.Pos(), fmt.Sprintf("Cannot delete this.\n\tTry deleting from a dimensioned metric with this as an index."))

}

Expand Down
6 changes: 6 additions & 0 deletions internal/vm/checker/checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ next
@x {}
}`,
[]string{"use decorator in decorator:2:1-2: Decorator `@x' is not completely defined yet.", "\tTry removing @x from here.", "use decorator in decorator:2:1-2: No symbols found in decorator `@x'.", "\tTry adding a `next' statement inside the `{}' block."}},

{"delete incorrect object",
`/(.*)/ {
del $0
}`,
[]string{"delete incorrect object:3:7: Cannot delete this.", "\tTry deleting from a dimensioned metric with this as an index."}},
}

func TestCheckInvalidPrograms(t *testing.T) {
Expand Down

0 comments on commit d609012

Please sign in to comment.