title: Lua - "attempt to compare number with nil" error
body: <pre><code>a={51,31,4,22,23,45,23,43,54,22,11,34}
  colors={"white","white","white","white","white","white","white","white","white","white","white","white","white","white","white","white","white"}
  function try(f, catch_f)
      local status, exception = pcall(f)
      if not status then
          catch_f(exception)
      end
  end
  function refreshColors(yellowEndIndex,redIndex,blueIndex)
          for ccnt=1,table.getn(a),1 do
                  if ccnt &lt; yellowEndIndex then
                      colors[ccnt] = "yellow"
                  elseif ccnt == redIndex then
                      colors[ccnt] = "red"
                  elseif ccnt == blueIndex then
                      colors[ccnt] = "blue"
                  else
                      colors[ccnt] = "white"
                  end
          end
  end
  try(refreshColors, function(e)
      print("Error Occured - "..e)
  end)
  refreshColors(1,1,1)
  print(colors[1])
  </code></pre>
  
  <p>When the refreshColors() function is called, it throws an exception and the error message is "Error Occured - trial.lua:11: attempt to compare number with nil". Why the exception occurs although there is no such comparisons in the refreshColors() function?</p>