Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not sure what it's called? #10

Open
erlandsona opened this issue Oct 14, 2019 · 0 comments
Open

Not sure what it's called? #10

erlandsona opened this issue Oct 14, 2019 · 0 comments

Comments

@erlandsona
Copy link

I've got a function in my demo app which I have spec'd to take any atom, and a branch which checks if it's in a subset of terms to create my struct, otherwise it will raise an ArgumentError. But this won't type check I'm assuming for similar reasons as my previous issue... But for reference, here's the snippet I changed to a stack of or's cause I thought it might have to do with st in [:a, :b, :c, :d, :etc] but same error either way.

  @spec new!(atom()) :: t() | no_return()
  def new!(st) do
    if st == :oregon or
         st == :washington or
         st == :colorado or
         st == :tennessee or
         st == :new_york do
      %__MODULE__{_: st}
    else
      raise(ArgumentError, "Unrecognized state")
    end
  end

errors with

❌  St.new!/1
   |
   | type `%St{_: atom()}` not match with union type `%St{_: :washington | :tennessee | :oregon | :new_york | :colorado}`
   |
   | at unknown_file:?
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

No branches or pull requests

1 participant