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

transition_to spec limits state to String type #82

Open
kyleboe opened this issue Nov 11, 2022 · 0 comments
Open

transition_to spec limits state to String type #82

kyleboe opened this issue Nov 11, 2022 · 0 comments

Comments

@kyleboe
Copy link

kyleboe commented Nov 11, 2022

In the spec definition for transition_to it specifies String.t() as the next_state's type.

@spec transition_to(struct, module, String.t()) :: {:ok, struct} | {:error, String.t()}

I believe this is incorrect. An atom is used in examples & typespecs for the state argument(s). I also confirmed locally that using atom states does not cause any errors.

Should a typespec be added for state? Possibly something like so:

@typedoc """
A state should be a string or an atom. Whichever corresponds with the underlying state field on the given struct.
"""
@type state :: atom | String.t()
@kyleboe kyleboe changed the title transition_to spec limits state to string type transition_to spec limits state to String type Nov 11, 2022
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