【发布时间】:2016-04-05 21:16:33
【问题描述】:
我正在使用“-Woverspecs”运行 Dialyzer 并收到以下警告:
room_channel.ex:143:
Type specification 'Elixir.Backend.RoomChannel':
testU(a) -> a when is_subtype(a,#{})
is a subtype of the success typing: 'Elixir.Backend.RoomChannel':testU(_) -> any()
使用此代码:
@spec testU( a ) :: a when a: %Backend.User{}
def testU(u) do
...
我想做的是用一个守卫确定函数类型,这样子类型警告就会消失,我对我的函数有一个精确的定义。
我在 Erlang 文档中看到不鼓励使用 -Woverspecs,并且我怀疑我是在违背常规,因为我能想到的唯一解决方案是一些复杂的函数保护...
有什么想法或建议吗?
【问题讨论】: