tletcolon.nim 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. discard """
  2. output: '''boo
  3. 3
  4. 44 3
  5. more body code
  6. yes
  7. yes
  8. block expression works'''
  9. """
  10. template x(body): untyped =
  11. body
  12. 44
  13. template y(val, body): untyped =
  14. body
  15. val
  16. proc mana =
  17. let foo = x:
  18. echo "boo"
  19. var foo2: int
  20. foo2 = y 3:
  21. echo "3"
  22. echo foo, " ", foo2
  23. mana()
  24. let other = x:
  25. echo "more body code"
  26. if true:
  27. echo "yes"
  28. else:
  29. echo "no"
  30. let outer = y(5):
  31. echo "yes"
  32. # bug #6609
  33. type
  34. TextureInternalFormat = enum RED, RGB, RGBA
  35. const channels = 4
  36. let format =
  37. if channels == 1:
  38. TextureInternalFormat.RED
  39. elif channels == 3:
  40. TextureInternalFormat.RGB
  41. elif channels == 4:
  42. TextureInternalFormat.RGBA
  43. else:
  44. echo "Texture Format Unknown, assuming RGB" #This echo causes an error
  45. TextureInternalFormat.RGB
  46. # Block as expressions #3827
  47. block:
  48. let x = block:
  49. var y = 2
  50. echo "block expression works"
  51. y*y
  52. doAssert x == 4
  53. # bug 10861
  54. macro foo(a: untyped): untyped =
  55. a
  56. let c1 = foo:
  57. 1 + 1
  58. const c2 = foo:
  59. 1 + 1
  60. const c3 =
  61. foo: 1 + 1