tconstarrayresem.nim 472 B

123456789101112131415161718192021222324252627282930
  1. # issue #23010
  2. type
  3. Result[T, E] = object
  4. case oResult: bool
  5. of false:
  6. discard
  7. of true:
  8. vResult: T
  9. Opt[T] = Result[T, void]
  10. template ok[T, E](R: type Result[T, E], x: untyped): R =
  11. R(oResult: true, vResult: x)
  12. template c[T](v: T): Opt[T] = Opt[T].ok(v)
  13. type
  14. FixedBytes[N: static[int]] = distinct array[N, byte]
  15. H = object
  16. d: FixedBytes[2]
  17. const b = default(H)
  18. template g(): untyped =
  19. const t = default(H)
  20. b
  21. discard c(g())