tproc_mismatch.nim 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. discard """
  2. action: reject
  3. cmd: '''nim check --hints:off $options $file'''
  4. nimoutFull: true
  5. nimout: '''
  6. tproc_mismatch.nim(35, 52) Error: type mismatch: got <proc (a: int, c: float){.cdecl, noSideEffect, gcsafe, locks: 0.}> but expected 'proc (a: int, c: float){.closure, noSideEffect.}'
  7. Calling convention mismatch: got '{.cdecl.}', but expected '{.closure.}'.
  8. tproc_mismatch.nim(39, 6) Error: type mismatch: got <proc (){.inline, noSideEffect, gcsafe, locks: 0.}>
  9. but expected one of:
  10. proc bar(a: proc ())
  11. first type mismatch at position: 1
  12. required type for a: proc (){.closure.}
  13. but expression 'fn1' is of type: proc (){.inline, noSideEffect, gcsafe, locks: 0.}
  14. Calling convention mismatch: got '{.inline.}', but expected '{.closure.}'.
  15. expression: bar(fn1)
  16. tproc_mismatch.nim(43, 8) Error: type mismatch: got <proc (){.inline, noSideEffect, gcsafe, locks: 0.}> but expected 'proc (){.closure.}'
  17. Calling convention mismatch: got '{.inline.}', but expected '{.closure.}'.
  18. tproc_mismatch.nim(48, 8) Error: type mismatch: got <proc (){.locks: 0.}> but expected 'proc (){.closure, noSideEffect.}'
  19. Pragma mismatch: got '{..}', but expected '{.noSideEffect.}'.
  20. tproc_mismatch.nim(52, 8) Error: type mismatch: got <proc (a: int){.noSideEffect, gcsafe, locks: 0.}> but expected 'proc (a: float){.closure.}'
  21. tproc_mismatch.nim(61, 9) Error: type mismatch: got <proc (a: int){.locks: 0.}> but expected 'proc (a: int){.closure, gcsafe.}'
  22. Pragma mismatch: got '{..}', but expected '{.gcsafe.}'.
  23. tproc_mismatch.nim(69, 9) Error: type mismatch: got <proc (a: int): int{.nimcall.}> but expected 'proc (a: int): int{.cdecl.}'
  24. Calling convention mismatch: got '{.nimcall.}', but expected '{.cdecl.}'.
  25. tproc_mismatch.nim(70, 9) Error: type mismatch: got <proc (a: int): int{.cdecl.}> but expected 'proc (a: int): int{.nimcall.}'
  26. Calling convention mismatch: got '{.cdecl.}', but expected '{.nimcall.}'.
  27. tproc_mismatch.nim(74, 9) Error: type mismatch: got <proc (a: int){.closure, locks: 3.}> but expected 'proc (a: int){.closure, locks: 1.}'
  28. Pragma mismatch: got '{.locks: 3.}', but expected '{.locks: 1.}'.
  29. lock levels differ
  30. '''
  31. """
  32. block: # CallConv mismatch
  33. func a(a: int, c: float) {.cdecl.} = discard
  34. var b: proc(a: int, c: float) {.noSideEffect.} = a
  35. block: # Parameter CallConv mismatch
  36. proc fn1() {.inline.} = discard
  37. proc bar(a: proc()) = discard
  38. bar(fn1)
  39. block: # CallConv mismatch
  40. proc fn1() {.inline.} = discard
  41. var fn: proc()
  42. fn = fn1
  43. block: # Pragma mismatch
  44. var a = ""
  45. proc fn1() = a.add "b"
  46. var fn: proc() {.noSideEffect.}
  47. fn = fn1
  48. block: # Fail match not do to Pragma or CallConv
  49. proc fn1(a: int) = discard
  50. var fn: proc(a: float)
  51. fn = fn1
  52. block: # Infered noSideEffect assign
  53. type Foo = ref object
  54. x0: int
  55. var g0 = Foo(x0: 1)
  56. proc fn1(a: int) = g0.x0 = a
  57. var fn2: proc(a: int)
  58. var fn3: proc(a: int) {.gcsafe.}
  59. fn2 = fn1
  60. fn3 = fn1
  61. block: # Indrection through pragmas
  62. {.pragma: inl1, inline.}
  63. {.pragma: inl2, inline.}
  64. {.pragma: p1, nimcall.}
  65. {.pragma: p2, cdecl.}
  66. var fn1: proc(a: int): int {.inl1, p1.}
  67. var fn2: proc(a: int): int {.inl2, p2.}
  68. fn2 = fn1
  69. fn1 = fn2
  70. block: # Lock levels differ
  71. var fn1: proc(a: int){.locks: 3.}
  72. var fn2: proc(a: int){.locks: 1.}
  73. fn2 = fn1