taliassyntaxerrors.nim 763 B

1234567891011121314151617181920212223242526272829
  1. discard """
  2. cmd: "nim check --hints:off $file"
  3. """
  4. block: # with params
  5. type Foo = object
  6. bar: int
  7. var foo = Foo(bar: 10)
  8. template bar(x: int): int = x + foo.bar
  9. let a = bar #[tt.Error
  10. ^ invalid type: 'template (x: int): int' for let. Did you mean to call the template with '()'?]#
  11. bar = 15 #[tt.Error
  12. ^ 'bar' cannot be assigned to]#
  13. block: # generic template
  14. type Foo = object
  15. bar: int
  16. var foo = Foo(bar: 10)
  17. template bar[T]: T = T(foo.bar)
  18. let a = bar #[tt.Error
  19. ^ invalid type: 'template (): T' for let. Did you mean to call the template with '()'?; tt.Error
  20. ^ 'bar' has unspecified generic parameters]#
  21. let b = bar[float]()
  22. doAssert b == 10.0
  23. bar = 15 #[tt.Error
  24. ^ 'bar' cannot be assigned to]#