diff --git a/test/should_fail/named_fun_fail.erl b/test/should_fail/named_fun_fail.erl index 17d3938b..dee7976b 100644 --- a/test/should_fail/named_fun_fail.erl +++ b/test/should_fail/named_fun_fail.erl @@ -1,6 +1,6 @@ -module(named_fun_fail). --export([bar/0, baz/1]). +-export([bar/0, baz/1, sum/1]). -spec foo(integer()) -> integer(). foo(N) -> N. @@ -11,3 +11,12 @@ bar() -> foo(fun F(0) -> 0; F(X) -> F(X - 1) end). baz(I) -> O = I({}), O. + +-spec sum([integer()]) -> integer(). +sum(Ints) -> + F = fun Sum(Acc, [Int | Rest]) -> + Sum(Acc + Int, Rest); + Sum(Acc, []) -> + Acc + end, + F(Ints). diff --git a/test/should_pass/named_fun_pass.erl b/test/should_pass/named_fun_pass.erl index 7ad911d6..c5307fd6 100644 --- a/test/should_pass/named_fun_pass.erl +++ b/test/should_pass/named_fun_pass.erl @@ -1,6 +1,6 @@ -module(named_fun_pass). --export([fac/1, sum/1]). +-export([fac/1]). -spec fac(integer()) -> integer(). fac(I) -> @@ -10,14 +10,3 @@ fac(I) -> N*Fac(N-1) end, F(I). - -%% Documents expected behaviour that named_fun gets type any() when -%% infer is off in do_type_check_expr. --spec sum([integer()]) -> integer(). -sum(Ints) -> - F = fun Sum(Acc, [Int | Rest]) -> - Sum(Acc + Int, Rest); - Sum(Acc, []) -> - Acc - end, - F(Ints).