erlang: function called with real 'fun' should be transformed with parse_transform?

29 阅读1分钟

问题描述:

 {badarg,{ets,fun2ms,[function,called,with,real,'fun',should,be,transformed,with,parse_transform,'or',called,with,a,'fun',generated,in,the,shell]}}

问题解决: 

Reading from the official documentation:

Pseudo function that by means of a parse_transform translates LiteralFun typed as parameter in the function call to a match_spec. With "literal" is meant that the fun needs to textually be written as the parameter of the function,  it cannot be held in a variable which in turn is passed to the function).

意思就是:fun2ms函数必须以文本形式写成函数的参数,它不能保存在一个变量中,然后传递给函数。