timplicit.nim 526 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. discard """
  2. output: '''
  3. 1
  4. 2
  5. 3
  6. 4
  7. 2
  8. 88
  9. timplicit done
  10. '''
  11. """
  12. for x in [1, 2, 3, 4]:
  13. echo x
  14. type
  15. TValue* {.pure, final.} = object of RootObj
  16. a: int
  17. PValue = ref TValue
  18. PPValue = ptr PValue
  19. var x: PValue
  20. new x
  21. var sp: PPValue = addr x
  22. sp.a = 2
  23. if sp.a == 2: echo 2 # with sp[].a the error is gone
  24. # Test the new auto-deref a little
  25. {.experimental.}
  26. proc p(x: var int; y: int) = x += y
  27. block:
  28. var x: ref int
  29. new(x)
  30. x.p(44)
  31. var indirect = p
  32. x.indirect(44)
  33. echo x[]
  34. echo "timplicit done"