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

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

Errors:

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

What the compiler wants?

DSblizzard
  • 4,007
  • 7
  • 48
  • 76
  • Some time ago I had a related [question on whether parameters have an address](http://stackoverflow.com/q/30132599/1804173) -- maybe it helps as well. – bluenote10 Aug 13 '15 at 19:43

1 Answers1

4

[] does not return a var.

I don't think you need to annotate anything in this snippet with var though, since nothing is being mutated. Specify var at the call site if needed.

Try to submit compilable examples in the future if you can.

ephja
  • 56
  • 2
  • 2
    You can also index the last element by doing list[^1], and the element before that by doing list[^2] – ephja Aug 13 '15 at 19:01