[erlang-patches] EEP37: Funs with names

Björn Gustavsson bgustavsson@REDACTED
Thu Nov 28 13:44:43 CET 2013


On Wed, Nov 14, 2012 at 5:42 PM, Anthony Ramine <n.oxyde@REDACTED> wrote:

> This patch implements EEP37: Funs with names
>
>
It is now much closer to being graduated.

I have added the branch to our daily builds for the master branch.

I would like a comment from Kostis about the Dialyzer changes.

What also remains is coverage in test suites. I have fixed a few,
but xref_SUITE remains to be fixed (a named fun with the '_' name
should be tested).

Here are my fixes for the test suites (also included as an attachment
to make it easier to apply):

diff --git a/lib/compiler/test/fun_SUITE.erl
b/lib/compiler/test/fun_SUITE.erl
index 0ff846e..e35692e 100644
--- a/lib/compiler/test/fun_SUITE.erl
+++ b/lib/compiler/test/fun_SUITE.erl
@@ -197,10 +197,14 @@ external(Config) when is_list(Config) ->
 call_me(I) ->
     {ok,I}.

-id(I) ->
-    I.
-
 eep37(Config) when is_list(Config) ->
     F = fun Fact(N) when N > 0 -> N * Fact(N - 1); Fact(0) -> 1 end,
+    Add = fun _(N) -> N + 1 end,
+    UnusedName = fun BlackAdder(N) -> N + 42 end,
     720 = F(6),
+    10 = Add(9),
+    50 = UnusedName(8),
     ok.
+
+id(I) ->
+    I.
diff --git a/lib/debugger/test/fun_SUITE.erl
b/lib/debugger/test/fun_SUITE.erl
index 569af6c..75e3b55 100644
--- a/lib/debugger/test/fun_SUITE.erl
+++ b/lib/debugger/test/fun_SUITE.erl
@@ -288,10 +288,14 @@ external(Config) when is_list(Config) ->
 call_me(I) ->
     {ok,I}.

-id(I) ->
-    I.
-
 eep37(Config) when is_list(Config) ->
     F = fun Fact(N) when N > 0 -> N * Fact(N - 1); Fact(0) -> 1 end,
+    Add = fun _(N) -> N + 1 end,
+    UnusedName = fun BlackAdder(N) -> N + 42 end,
     720 = F(6),
+    10 = Add(9),
+    50 = UnusedName(8),
     ok.
+
+id(I) ->
+    I.
diff --git a/lib/stdlib/test/erl_lint_SUITE.erl
b/lib/stdlib/test/erl_lint_SUITE.erl
index ea90793..ad51bfa 100644
--- a/lib/stdlib/test/erl_lint_SUITE.erl
+++ b/lib/stdlib/test/erl_lint_SUITE.erl
@@ -644,7 +644,9 @@ unused_vars_warn_fun(Config) when is_list(Config) ->
               u() ->
                   fun U(U) -> foo end; % U shadowed. U unused.
               u() ->
-                  fun U(1) -> U; U(U) -> foo end. % U shadowed. U unused.
+                  fun U(1) -> U; U(U) -> foo end; % U shadowed. U unused.
+              u() ->
+                  fun _(N) -> N + 1 end.  % Cover handling of '_' name.
            ">>,
            [warn_unused_vars],
            {error,[{3,erl_lint,{unbound_var,'U'}}],


id/1 is a common help function, so I want it to remain at the end
of the file.

/Bjorn

-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20131128/1d0eca39/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-fixup-Test-named-funs.patch
Type: text/x-patch
Size: 2323 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20131128/1d0eca39/attachment.bin>


More information about the erlang-patches mailing list