Last active
February 26, 2016 11:52
-
-
Save TattdCodeMonkey/2d634edabebd8d4cbf2e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Nothing do | |
defstruct([]) | |
@type t :: %__MODULE__{} | |
end | |
defmodule Name do | |
defstruct first: "", last: "" | |
@type t :: %__MODULE__{first: String.t, last: String.t} | |
end | |
defmodule Character do | |
@type t :: %__MODULE__{ | |
name: Name.t | Nothing.t | |
} | |
defstruct name: %Nothing{} | |
# dialyzer return an error for this function | |
@spec return_test :: Name.t | Nothing.t | |
def return_test, do: "Dan" | |
# dialyzer does not give an error for this function event though | |
# name does is a string instead of Name.t | Nothing.t | |
@spec return_dan :: __MODULE__.t | |
def return_dan, do: %Character{name: "Dan"} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment