Skip to content

Commit

Permalink
Fix test/should_pass/named_fun_pass.erl
Browse files Browse the repository at this point in the history
  • Loading branch information
erszcz committed Oct 11, 2024
1 parent 76c43e4 commit a394b13
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
11 changes: 10 additions & 1 deletion test/should_fail/named_fun_fail.erl
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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).
13 changes: 1 addition & 12 deletions test/should_pass/named_fun_pass.erl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-module(named_fun_pass).

-export([fac/1, sum/1]).
-export([fac/1]).

-spec fac(integer()) -> integer().
fac(I) ->
Expand All @@ -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).

0 comments on commit a394b13

Please sign in to comment.