erlang “之前语法错误:“/”“当做二郎使

4sup72z8  于 2022-12-08  发布在  Erlang
关注(0)|答案(1)|浏览(169)

当我使用Erlang pjt进行make时,会出现如下错误:第一次访问:44:10之前出现语法错误:'/'
源代码:

-module(Memcached).
%% External API
-export([set/3, set/5]).
-export([add/3, add/5]).
-export([replace/3, replace/5]).
-export([get/2]).
-export([delete/3, delete/2]).
-export([stats/1]).
%%====================================================================
%% Types
%%====================================================================
%% @type hostport() = {host, string(), port, integer()}. Tuple describing a host and port to connect to
%% @type socket() = {socket, port()}. Tuple describing an existing socket
%% @type memcached_connection() = hostport() | socket().
%% @type memcached_key() = list() | atom().
-type(hostport() :: {host, string(), port, integer()}).
-type(socket() :: {socket, port()}).
-type(memcached_connection() :: hostport() | socket()).
-type(memcached_key() :: list() | atom()).
%%====================================================================
%% External API
%%====================================================================
%% @doc Associate Bytes with Key.
%% @spec set(memcached_connection(), Key::memcached_key(), Bytes::any()) ->
%%         ok | {error, not_stored}
-spec(set/3::(memcached_connection(), memcached_key(), any()) ->
     ok | {error, not_stored}).
set({host, Host, port, Port}, Key, Bytes) ->
set({host, Host, port, Port}, Key, 0, 0, Bytes);
set({socket, Socket}, Key, Bytes) ->
set({socket, Socket}, Key, 0, 0, Bytes).

错误位于-spec(set/3::(memcached_connection(), memcached_key(), any())
我检查了很多文档试图解决它,但错误仍然存在。是否有拼写错误或Erlang语法误用?
我的erl环境信息:

Erlang/OTP 24 [erts-12.1.5] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1]

Eshell V12.1.5  (abort with ^G)
1>
nhjlsmyf

nhjlsmyf1#

此语法已过时:

-spec(set/3::(memcached_connection(), memcached_key(), any()) ->
     ok | {error, not_stored}).

当前语法为:

-spec set(memcached_connection(), memcached_key(), any()) ->
     ok | {error, not_stored}.

我试图找出Erlang的哪个版本放弃了对旧语法的支持,但我找不到它--肯定是很久以前的事了。

相关问题