tdiagnostic_messages.nim 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. discard """
  2. nimoutFull: true
  3. action: "reject"
  4. cmd: "nim r --hint:Conf:off $file"
  5. nimout: '''
  6. tdiagnostic_messages.nim(36, 6) Error: 'a' can have side effects
  7. > tdiagnostic_messages.nim(37, 30) Hint: 'a' calls `.sideEffect` 'callWithSideEffects'
  8. >> tdiagnostic_messages.nim(29, 6) Hint: 'callWithSideEffects' called by 'a'
  9. >>> tdiagnostic_messages.nim(31, 34) Hint: 'callWithSideEffects' calls `.sideEffect` 'indirectCallViaVarParam'
  10. >>>> tdiagnostic_messages.nim(25, 6) Hint: 'indirectCallViaVarParam' called by 'callWithSideEffects'
  11. >>>>> tdiagnostic_messages.nim(26, 7) Hint: 'indirectCallViaVarParam' calls routine via hidden pointer indirection
  12. >>> tdiagnostic_messages.nim(32, 33) Hint: 'callWithSideEffects' calls `.sideEffect` 'indirectCallViaPointer'
  13. >>>> tdiagnostic_messages.nim(27, 6) Hint: 'indirectCallViaPointer' called by 'callWithSideEffects'
  14. >>>>> tdiagnostic_messages.nim(28, 32) Hint: 'indirectCallViaPointer' calls routine via pointer indirection
  15. >>> tdiagnostic_messages.nim(33, 10) Hint: 'callWithSideEffects' calls `.sideEffect` 'myEcho'
  16. >>>> tdiagnostic_messages.nim(24, 6) Hint: 'myEcho' called by 'callWithSideEffects'
  17. >>> tdiagnostic_messages.nim(34, 3) Hint: 'callWithSideEffects' accesses global state 'globalVar'
  18. >>>> tdiagnostic_messages.nim(23, 5) Hint: 'globalVar' accessed by 'callWithSideEffects'
  19. '''
  20. """
  21. var globalVar = 0
  22. proc myEcho(a: string) {.sideEffect.} = discard
  23. proc indirectCallViaVarParam(call: var proc(): int {.nimcall.}): int =
  24. call()
  25. proc indirectCallViaPointer(call: pointer): int =
  26. cast[ptr proc(): int](call)[]()
  27. proc callWithSideEffects(): int =
  28. var p = proc (): int {.nimcall.} = 0
  29. discard indirectCallViaVarParam(p)
  30. discard indirectCallViaPointer(addr p)
  31. myEcho ""
  32. globalVar
  33. func a: int =
  34. discard callWithSideEffects()