public override VariableValue Evaluate(IVariableStore variables) { var left = Left.Evaluate(variables); if (left.HasList) { var result = left.List.Count > 0 ? left.List.RemoveVariable(left.List.Count - 1) : SetVariableResult.NotFound; if (result != SetVariableResult.Success) { switch (result) { case SetVariableResult.NotFound: throw new ExpressionEvaluationException(_missingRemoveException, Left); case SetVariableResult.ReadOnly: throw new ExpressionEvaluationException(_readOnlyRemoveException, Left); case SetVariableResult.TypeMismatch: throw new ExpressionEvaluationException(_mismatchedRemoveException, Left); } } return(left); } else { var value = VariableHandler.Add(left, VariableValue.Create(-1)); if (value.IsEmpty) { throw TypeMismatch(left.Type, VariableType.Int); } Assign(variables, value); return(left); } }