tableinstatic.nim 529 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. discard """
  2. nimout: '''0
  3. 0
  4. 0
  5. {hallo: 123, welt: 456}'''
  6. """
  7. import tables
  8. # bug #5327
  9. type
  10. MyType* = object
  11. counter: int
  12. proc foo(t: var MyType) =
  13. echo t.counter
  14. proc bar(t: MyType) =
  15. echo t.counter
  16. static:
  17. var myValue: MyType
  18. myValue.foo # works nicely
  19. var refValue: ref MyType
  20. refValue.new
  21. refValue[].foo # fails to compile
  22. refValue[].bar # works again nicely
  23. static:
  24. var otherTable = newTable[string, string]()
  25. otherTable["hallo"] = "123"
  26. otherTable["welt"] = "456"
  27. echo otherTable