tundeclared_field.nim 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. discard """
  2. cmd: '''nim check --hints:off $file'''
  3. action: reject
  4. nimout: '''
  5. tundeclared_field.nim(25, 12) Error: undeclared field: 'bad1' for type tundeclared_field.A [type declared in tundeclared_field.nim(22, 8)]
  6. tundeclared_field.nim(30, 17) Error: undeclared field: 'bad2' for type tundeclared_field.A [type declared in tundeclared_field.nim(28, 8)]
  7. tundeclared_field.nim(36, 4) Error: undeclared field: 'bad3' for type tundeclared_field.A [type declared in tundeclared_field.nim(33, 8)]
  8. tundeclared_field.nim(42, 12) Error: undeclared field: 'bad4' for type tundeclared_field.B [type declared in tundeclared_field.nim(39, 8)]
  9. tundeclared_field.nim(43, 4) Error: undeclared field: 'bad5' for type tundeclared_field.B [type declared in tundeclared_field.nim(39, 8)]
  10. tundeclared_field.nim(44, 23) Error: undeclared field: 'bad6' for type tundeclared_field.B [type declared in tundeclared_field.nim(39, 8)]
  11. tundeclared_field.nim(46, 19) Error: undeclared field: 'bad7' for type tundeclared_field.B [type declared in tundeclared_field.nim(39, 8)]
  12. tundeclared_field.nim(50, 13) Error: cannot instantiate Foo [type declared in tundeclared_field.nim(49, 8)]
  13. '''
  14. """
  15. #[
  16. xxx in future work, generic instantiations (e.g. `B[int]`) should be shown with their instantiation instead of `tundeclared_field.B`,
  17. maybe using TPreferedDesc.preferResolved or preferMixed
  18. ]#
  19. # line 20
  20. block:
  21. type A = object
  22. a0: int
  23. var a: A
  24. discard a.bad1
  25. block:
  26. type A = object
  27. a0: int
  28. var a = A(bad2: 0)
  29. block:
  30. type A = object
  31. a0: int
  32. var a: A
  33. a.bad3 = 0
  34. block:
  35. type B[T] = object
  36. b0: int
  37. var b: B[int]
  38. discard b.bad4
  39. b.bad5 = 0
  40. var b2 = B[int](bad6: 0)
  41. type Bi = B[int]
  42. var b3 = Bi(bad7: 0)
  43. block:
  44. type Foo[T: SomeInteger] = object
  45. var a: Foo[float]