   reduce: ->
     until @stack.length < 2
       operation = @stack.pop()
+      unless @peekTop().setTarget?
+        throw new OperationStackError("The top operation in operation stack is not operator!")
       @peekTop().setTarget(operation)
 
   reset: ->

    catch error
      if error.instanceof?('OperatorError')
        @vimState.resetNormalMode()
      else
        throw error


{moveCursorLeft} = require './utils'
settings = require './settings'
{CurrentSelection, Select, MoveToRelativeLine} = {}


class OperationStackError extends Error
  constructor: ({@message}) ->
    @name = @constructor.name

class OperationStack
  constructor: (@vimState) ->
