Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

escript: exception error: undefined function erl_eval:expr/3 #14

Open
johnzeng opened this issue Mar 21, 2017 · 6 comments
Open

escript: exception error: undefined function erl_eval:expr/3 #14

johnzeng opened this issue Mar 21, 2017 · 6 comments
Assignees

Comments

@johnzeng
Copy link
Contributor

I get this exception on my mac when I tried to find external functions of jiffy.

OSX 10.11.6, and erlang version is 19.

I also tested on ubuntu12.04, which is running R16B02 on it, it returns fine but with another error msg:

/mnt/hgfs/working/xxx/deps/jiffy/src/jiffy.erl: at line 32: syntax error before: '{'

This error is caused by mapping syntex, which is not supported in R16, and jiffy has a define for it, but it seems that the edoc api doesn't read the jiffy's config:

{erl_opts, [
    {platform_define, "R1(1|2|3|4|5|6)", 'JIFFY_NO_MAPS'}
]}.
@hcs42
Copy link
Member

hcs42 commented Mar 22, 2017

What is the exception on "OSX 10.11.6, and erlang version is 19."?

@johnzeng
Copy link
Contributor Author

johnzeng commented Mar 23, 2017

@hcs42

 escript: exception error: undefined function erl_eval:expr/3

Sorry, I thought you should read the title.

@hcs42 hcs42 self-assigned this Mar 23, 2017
@hcs42
Copy link
Member

hcs42 commented Mar 23, 2017

Sorry, I missed it :)

On OSX, it looks as if you had an incomplete Erlang installation which doesn't have the erl_eval:expr/3 function. According to the documentation, that function is present in the newest Erlang versions as well.

Could you try whether you have this function by trying to call it directly:

$ erl
Erlang R16B03 (erts-5.10.4) [source] [64-bit] [smp:4:4] [async-threads:10]
[kernel-poll:false]

Eshell V5.10.4  (abort with ^G)
1> erl_eval:expr(a,b,c).
** exception error: no function clause matching
erl_eval:expr(a,b,c,none,none) (erl_eval.erl, line 200)
2> 

You can also write a small escript to make sure that the Erlang installation used by escripts has this module:

#!/usr/bin/env escript

main(_) ->
    erl_eval:expr(a,b,c).

Execution:

$ ./x.es 
escript: exception error: no function clause matching
erl_eval:expr(a,b,c,none,none) (erl_eval.erl, line 200)
  in function  erl_eval:local_func/5 (erl_eval.erl, line 467)
  in call from escript:interpret/4 (escript.erl, line 774)
  in call from escript:start/1 (escript.erl, line 277)
  in call from init:start_it/1 
  in call from init:start_em/1 

If you see "undefined function" errors instead of the "no function clause" errors, then there is something wrong with the installation.

On Linux, you are right in what the cause of the error is. This is a missing feature from vim-erlang-omnicomplete; it doesn't define macros based on platform_define.

@johnzeng
Copy link
Contributor Author

Hmm, looks like I am using an incomplete version of erlang. But another interesting thing is that this exception only happens when I try to find external functions for jiffy, other modules are working fine. And this exception is thrown when calling case code:where_is_file(BeamFile) of inside module_edoc(Mod) , I think code:where_is_file is calling erl_eval somewhere deep inside. Either you use another way to find the code, or I install a fully installed version of erlang may solve this problem

@hcs42
Copy link
Member

hcs42 commented Mar 25, 2017

Probably completion for the other applications work because the filename:find_src call inside module_edoc finds the file in those cases, so code:where_is_file is not called.

I suggest you install a complete Erlang version (it seems to be a reasonable expectation from vim-erlang-omnicomplete to expect that each function that is part of Erlang is available).

With regard to the platform_define problem, pull requests are welcome :)

@johnzeng
Copy link
Contributor Author

I think it's caused by the platform_define problem, as I compiled the code on R16B, so the beam file is encoded in R16B, but when I write codes, my laptop is running v19, so the problem happens, I tried to compile the jiffy on v19 and this plugin works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants