Last active
July 2, 2020 18:36
-
-
Save eksperimental/55f1e207ab5878a668668546f57a3f90 to your computer and use it in GitHub Desktop.
Broken types in Elixir Issue #10140
This file contains 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
# Downloaded from: https://gist.github.com/eksperimental/55f1e207ab5878a668668546f57a3f90 | |
# | |
# Lists all the types that have the problem reported in | |
# https://github.com/elixir-lang/elixir/issues/10140 | |
# create an Elixir project, and save this file in lib/typespec_example.ex | |
# Start IEx with: iex -S mix | |
# then run: TypespecExample.types() | |
# and paste the output into the shell. | |
defmodule TypespecExample do | |
@type bar(key) :: [key] | |
@type bar2222(key) :: [key] | |
@type none(key) :: [key] | |
@type atom(key) :: [key] | |
@type map(key) :: [key] | |
@type pid(key) :: [key] | |
@type port(key) :: [key] | |
@type reference(key) :: [key] | |
@type tuple(key) :: [key] | |
@type float(key) :: [key] | |
@type integer(key) :: [key] | |
@type neg_integer(key) :: [key] | |
@type non_neg_integer(key) :: [key] | |
@type pos_integer(key) :: [key] | |
@type list(key, key) :: [key] | |
@type nonempty_list(key, key) :: [key] | |
@type maybe_improper_list(key) :: [key] | |
@type maybe_improper_list(key, key, key) :: [key] | |
@type nonempty_improper_list(key) :: [key] | |
@type nonempty_improper_list(key, key, key) :: [key] | |
@type nonempty_maybe_improper_list(key) :: [key] | |
@type nonempty_maybe_improper_list(key, key, key) :: [key] | |
@type term(key) :: [key] | |
@type arity(key) :: [key] | |
@type as_boolean(key, key) :: [key] | |
@type binary(key) :: [key] | |
@type bitstring(key) :: [key] | |
@type boolean(key) :: [key] | |
@type byte(key) :: [key] | |
@type char(key) :: [key] | |
@type charlist(key) :: [key] | |
@type nonempty_charlist(key) :: [key] | |
@type fun(key) :: [key] | |
@type function(key) :: [key] | |
@type identifier(key) :: [key] | |
@type iodata(key) :: [key] | |
@type iolist(key) :: [key] | |
@type keyword(key, key, key) :: [key] | |
@type mfa(key) :: [key] | |
@type module(key) :: [key] | |
@type no_return(key) :: [key] | |
@type node(key) :: [key] | |
@type number(key) :: [key] | |
@type struct(key) :: [key] | |
@type timeout(key) :: [key] | |
@type example_bar() :: bar(1) | |
@type example_none() :: none(1) | |
@type example_atom() :: atom(1) | |
@type example_map() :: map(1) | |
@type example_pid() :: pid(1) | |
@type example_port() :: port(1) | |
@type example_reference() :: reference(1) | |
@type example_tuple() :: tuple(1) | |
@type example_float() :: float(1) | |
@type example_integer() :: integer(1) | |
@type example_neg_integer() :: neg_integer(1) | |
@type example_non_neg_integer() :: non_neg_integer(1) | |
@type example_pos_integer() :: pos_integer(1) | |
@type example_list() :: list(1, 2) | |
@type example_nonempty_list() :: nonempty_list(1, 2) | |
@type example_maybe_improper_list() :: maybe_improper_list(1) | |
@type example_maybe_improper_list_3() :: maybe_improper_list(1, 2, 3) | |
@type example_nonempty_improper_list() :: nonempty_improper_list(1) | |
@type example_nonempty_improper_list_3() :: nonempty_improper_list(1, 2, 3) | |
@type example_nonempty_maybe_improper_list() :: nonempty_maybe_improper_list(1) | |
@type example_nonempty_maybe_improper_list_3() :: nonempty_maybe_improper_list(1, 2, 3) | |
@type example_term() :: term(1) | |
@type example_arity() :: arity(1) | |
@type example_as_boolean(key, key) :: as_boolean(1, 2) | |
@type example_binary() :: binary(1) | |
@type example_bitstring() :: bitstring(1) | |
@type example_boolean() :: boolean(1) | |
@type example_byte() :: byte(1) | |
@type example_char() :: char(1) | |
@type example_charlist() :: charlist(1) | |
@type example_nonempty_charlist() :: nonempty_charlist(1) | |
@type example_fun() :: fun(1) | |
@type example_function() :: function(1) | |
@type example_identifier() :: identifier(1) | |
@type example_iodata() :: iodata(1) | |
@type example_iolist() :: iolist(1) | |
@type example_keyword(key, key, key) :: keyword(1, 2, 3) | |
@type example_mfa() :: mfa(1) | |
@type example_module() :: module(1) | |
@type example_no_return() :: no_return(1) | |
@type example_node() :: node(1) | |
@type example_number() :: number(1) | |
@type example_struct() :: struct(1) | |
@type example_timeout() :: timeout(1) | |
@spec tuple(tuple(integer)) :: example_tuple() | |
def tuple({integer}) when is_integer(integer), | |
do: {integer, integer * 2} | |
@spec bar(bar(integer)) :: example_bar() | |
def bar({integer}) when is_integer(integer), | |
do: {integer, integer * 2} | |
require IEx.Helpers | |
def types() do | |
{:docs_v1, _, :elixir, _, _, _, docs} = Code.fetch_docs(__MODULE__) | |
types = | |
Enum.filter(docs, fn | |
{{:type, type_name, _type_arity}, _, _, _, _} -> | |
case Atom.to_string(type_name) do | |
<<"example_" <> _rest::binary >> -> | |
true | |
_ -> | |
false | |
end | |
_ -> | |
false | |
end) | |
for {{:type, type_name, arity}, _, _, _, _} <- types do | |
IO.puts("t #{__MODULE__}.#{type_name}/#{arity}") | |
end | |
:ok | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment