我已经定义了一个名为 node 的类型以及一个节点列表。
type node = {name: string; description: string}
nodes = [] : list(node)
我创建了一个名为的函数createNewNode()
,它创建一个新节点,将其分配给 selectedNode,并将其添加到数组节点中。
line 19: createNewNode() =
line 20: selectedNode = {name="" remoteFSRoot=""} : node
line 21: nodes = [nodes | selectedNode]
...
当我编译这个时,我得到以下错误:
Error
File "node.opa", line 21, characters 10-32, (21:10-21:32 | 592-614)
Expression has type { hd: list(node); tl: node } / 'c.a but is coerced into
list('a).
Types { name: string; description: string } and
{ hd: 'a; tl: list('a) } / { nil } are not compatible
Hint:
One of the sum types may be missing the following cases of the
other:
{ nil }
{ hd tl }.
此编译消息是什么意思,我该如何解决?