Skip to content

Private functions can't have contracts #34

Description

@asianfilm

You can't specify a contract for a private function.

For example:

defmodule Test do
  use Norm

  @contract public() :: :ok
  def public(), do: :ok

  @contract private() :: :ok
  defp private(), do: ok
end

Gives the error:

** (ArgumentError) contract for undefined function private/0

There's a strong argument that only contracts at a module's boundaries should have contracts (or tests). But the author has stated: "My goal is to build a system that allows you to validate any elixir data at any point in your stack."

My workaround for now is to make all my functions public.

PS: Take my flood of issues as evidence that I'm loving the library.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions