           t1 = visit node[1]
           for c in node[2...] when c isnt null
             t = visit c
-            assert t.type is 'X', 'Only data can be used as an index'
+            if t.type isnt 'X'
+              throw new CompilerError node,
+                'Only expressions of type data can be used as an index.'
           t1
         when 'expr'
           a = node[1...]

    #     A←5       ⍝ returns 5
    #     A×A←2 5   ⍝ returns 4 25
    when 'assign'
      assert node[1].constructor is Array
      assert node[1].length is 2
      assert node[1][0] is 'symbol'
      name = node[1][1]
      assert typeof name is 'string'
      assert name isnt '∇', 'Assignment to ∇ is not allowed.'
      vars = closestScope(node).vars
      if (v = vars["set_#{name}"])?.type is 'F'
        v.used = true

  while node[0] isnt 'body' then node = node.parent
  node

# Used to report the AST node where the error happened
@CompilerError =
  class CompilerError extends Error
    constructor: (@astNode, @message, args...) ->
      assert @astNode instanceof Array
      assert typeof @message is 'string'
      assert not args.length

# # Public interface to this module

