Skip to content

Fix Elixir 1.18 "clause will never match" warnings#13

Open
justinludwig wants to merge 1 commit intojfrolich:masterfrom
justinludwig:type-rule-result
Open

Fix Elixir 1.18 "clause will never match" warnings#13
justinludwig wants to merge 1 commit intojfrolich:masterfrom
justinludwig:type-rule-result

Conversation

@justinludwig
Copy link
Copy Markdown

Fixes warnings like the following by providing a hint to the Elixir compiler about the result type of rule blocks:

    warning: the following clause will never match:

        {:ok, description}

    because it attempts to match on the result of:

        case actor.admin? do
          x when x === false or x === nil -> :next
          _ -> :ok
        end

    which has type:

        dynamic(:next or :ok)

    typing violation found at:
    │
 51 │     rule [:update, :delete],
    │     ~~~~~~~~~~~~~~~~~~~~~~~~
    │
    └─ test/authorize_test.exs:51: Item."admins can update and delete any item"/3

Fixes warnings like the following by providing a hint to the Elixir
compiler about the result type of rule blocks:

```
    warning: the following clause will never match:

        {:ok, description}

    because it attempts to match on the result of:

        case actor.admin? do
          x when x === false or x === nil -> :next
          _ -> :ok
        end

    which has type:

        dynamic(:next or :ok)

    typing violation found at:
    │
 51 │     rule [:update, :delete],
    │     ~~~~~~~~~~~~~~~~~~~~~~~~
    │
    └─ test/authorize_test.exs:51: Item."admins can update and delete any item"/3
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant