tinconsistentgensym.nim 564 B

1234567891011121314151617181920212223242526
  1. discard """
  2. cmd: "nim check --hints:off $file"
  3. """
  4. block:
  5. template foo =
  6. when false:
  7. let x = 123
  8. else:
  9. template x: untyped {.inject.} = 456
  10. echo x #[tt.Error
  11. ^ undeclared identifier: 'x`gensym0'; if declared in a template, this identifier may be inconsistently marked inject or gensym]#
  12. foo()
  13. block:
  14. template foo(y: static bool) =
  15. block:
  16. when y:
  17. let x {.gensym.} = 123
  18. else:
  19. let x {.inject.} = 456
  20. echo x #[tt.Error
  21. ^ undeclared identifier: 'x']#
  22. foo(false)
  23. foo(true)