tarc_orc.nim 932 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. discard """
  2. targets: "c cpp"
  3. matrix: "--mm:arc; --mm:orc"
  4. """
  5. block:
  6. type
  7. PublicKey = array[32, uint8]
  8. PrivateKey = array[64, uint8]
  9. proc ed25519_create_keypair(publicKey: ptr PublicKey; privateKey: ptr PrivateKey) =
  10. publicKey[][0] = uint8(88)
  11. type
  12. KeyPair = object
  13. public: PublicKey
  14. private: PrivateKey
  15. proc initKeyPair(): KeyPair =
  16. ed25519_create_keypair(result.public.addr, result.private.addr)
  17. let keys = initKeyPair()
  18. doAssert keys.public[0] == 88
  19. template minIndexByIt: untyped =
  20. var other = 3
  21. other
  22. proc bug20303() =
  23. var hlibs = @["hello", "world", "how", "are", "you"]
  24. let res = hlibs[minIndexByIt()]
  25. doAssert res == "are"
  26. bug20303()
  27. proc main() = # todo bug with templates
  28. block: # bug #11267
  29. var a: seq[char] = block: @[]
  30. doAssert a == @[]
  31. # 2
  32. proc b: seq[string] =
  33. discard
  34. @[]
  35. doAssert b() == @[]
  36. static: main()
  37. main()