[erlang-bugs] R16B takes long to compile a simple module

Magnus Müller <>
Tue Mar 12 16:39:48 CET 2013


The following small module takes ~10s to compile with R16B (erl +V
below). The code is distilled from indent/erlang_indent.erl in vimerl
[1]. Diagnostics are fast (a small syntax error somewhere crashes the
compilation immediately). The same module compiles quickly (<1s) with R15B.

-------------------------------------------------
-module(erlang_indent).

-export([p/2]).

-define(IS(T, C), (element(1, T) == C)).

-record(state, {stack = []}).

p(T1, #state{stack = [T2 | _]}) when ?IS(T2, a), ?IS(T1, b), ?IS(T1, c)
-> ok; p(T, _) when ?IS(T, a1); ?IS(T, b1); ?IS(T, c1) -> ok;
p(T, _) when ?IS(T, a2); ?IS(T, b2); ?IS(T, c2) -> ok;
p(T, _) when ?IS(T, a) -> ok;
p(T, _) when ?IS(T, a), (?IS(T, b) and ?IS(T, c)) -> ok;
p(_, T) when ?IS(T, a) -> ok;
p(_, T) when ?IS(T, b) -> ok;
p(T, _) when ?IS(T, a) -> ok.
-------------------------------------------------

$ erl +V
Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 5.10.1


The original file[2] in vimerl takes even longer to compile. Note that
that [2] is actually an escript, but the error persists when
it is converted to a module.


[1] https://github.com/jimenezrick/vimerl
[2] https://raw.github.com/jimenezrick/vimerl/master/indent/erlang_indent.erl


More information about the erlang-bugs mailing list