Erlang Crash Dump is written to: erl_crash.dump ... done

So, I just started to learn some basic Erlang. I am working on the idea of ​​IntelliJ. I wrote a basic function to add two numbers:

-module(easy).
-author("var").

%% API
-export([add/2]).

add(X, Y) ->
  X + Y.

However, when I start, I get the following error:

{"init terminating in do_boot",{{badmatch,{error,{1,erl_parse,["syntax error before: ","','"]}}},[{init,start_it,1,[]},{init,start_em,1,[]}]}}

Crash dump is being written to: erl_crash.dump...done
init terminating in do_boot ()

I can’t understand exactly why this is happening. Is this related to the Run configuration for Idea?

+3
source share
1 answer

Not sure how you execute the code. Try the following steps.

Create a file containing the source code, in this case easy.erl, which you already have:

[g@somecomp:~/test]$ cat easy.erl 
-module(easy).
-author("var").

%% API
-export([add/2]).

add(X, Y) ->
    X + Y.

Now compile the module:

[g@somecomp:~/test]$ erlc easy.erl

Launch Erlang and load it from the shell:

[g@somecomp:~/test]$ erl
Erlang/OTP 18 [erts-7.2.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V7.2.1  (abort with ^G)
1> l(easy).
{module,easy}

In the shell, execute the function and close Erlang:

2> easy:add(1,2).
3
3> q().
ok
4> [g@somecomp:~/test]$ 

(bash, csh), :

[g@somecomp:~/test]$ erlc easy.erl
[g@somecomp:~/test]$ erl -noshell -eval 'io:format("~p~n", [easy:add(1,2)])' -s init stop
3
[g@somecomp:~/test]$
+2

Source: https://habr.com/ru/post/1629322/


All Articles