From 57262fe249ecd6c384b279b5ee236700f08e5057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20B=C3=A4renz?= Date: Fri, 25 Dec 2020 05:39:19 +0100 Subject: [PATCH] Fix #20 (#22) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add regression test for #20 * Allow functions without argument brackets. Fix #20. Co-authored-by: Manuel Bärenz --- lib/ex_type/custom_env.ex | 7 +++++++ test/ex_type/checker_test_case.ex | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/lib/ex_type/custom_env.ex b/lib/ex_type/custom_env.ex index 4c26e68..d22c8c0 100644 --- a/lib/ex_type/custom_env.ex +++ b/lib/ex_type/custom_env.ex @@ -34,6 +34,13 @@ defmodule ExType.CustomEnv do (defs ++ defps) # support "mix type" with filter + |> Enum.map(fn + {{:when, meta_when, [{name, meta, args}, guards]}, block} -> + {{:when, meta_when, [{name, meta, args || []}, guards]}, block} + + {{name, meta, args}, block} -> + {{name, meta, args || []}, block} + end) |> Enum.map(fn {{:when, _, [{name, _meta, args}, _guards]} = call, block} -> {call, block, name, length(args)} diff --git a/test/ex_type/checker_test_case.ex b/test/ex_type/checker_test_case.ex index 25c12b4..7c18633 100644 --- a/test/ex_type/checker_test_case.ex +++ b/test/ex_type/checker_test_case.ex @@ -32,4 +32,10 @@ defmodule ExType.CheckerTestCase do other end end + + @spec test_case_3() :: integer() + + def test_case_3 do + 23 + end end