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

Fix 39 #42

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions lib/ex_type/typespec.ex
Original file line number Diff line number Diff line change
Expand Up @@ -606,11 +606,7 @@ defmodule ExType.Typespec do
# type variable
def eval_type({name, meta, atom}, {_, vars} = context) when is_atom(name) and is_atom(atom) do
case vars do
%{^name => %Type.SpecVariable{} = type} ->
type

%{^name => raw} ->
eval_type(raw, context)
%{^name => type} -> type

_ ->
eval_type({name, meta, []}, context)
Expand Down
9 changes: 9 additions & 0 deletions test/ex_type/regression_39_failure_case.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule Regression39FailureCase do
@type t(elem) :: [elem]

@spec mylength(t(term())) :: integer()

def mylength(:foo) do
42
end
end
9 changes: 9 additions & 0 deletions test/ex_type/regression_39_test_case.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule Regression39TestCase do
@type t(elem) :: [elem]

@spec mylength(t(term())) :: integer()

def mylength(_) do
23
end
end
12 changes: 9 additions & 3 deletions test/ex_type_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ defmodule ExTypeTest do
use ExUnit.Case
doctest ExType

test "typespec/**/*_test_case.ex" do
for file <- Path.wildcard("#{__DIR__}/ex_type/**/*_test_case.ex") do
ExType.check(file)
for file <- Path.wildcard("#{__DIR__}/ex_type/**/*_test_case.ex") do
test "#{file}" do
ExType.check(unquote(file))
end
end

for file <- Path.wildcard("#{__DIR__}/ex_type/**/*_failure_case.ex") do
test "#{file}" do
ExType.check(unquote(file))
end
end
end