2
# lines 11-12:
proc last[T](ll: seq[T]): var T =
  return ll[high(ll)]

# line 118:
if last(formula)["state"] == c_empty:

错误:

main.nim(118, 12) Info: template/generic instantiation from here    
main.nim(12, 12) Error: expression has no address    

编译器想要什么?

4

1 回答 1

4

[]不返回 var。

不过,我认为您不需要在此代码段中使用var注释任何内容,因为没有任何内容发生突变。如果需要,请在调用站点指定var 。

如果可以,请尝试在将来提交可编译的示例。

于 2015-08-13T18:03:07.150 回答