tstrict_effects3.nim 933 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. discard """
  2. action: compile
  3. """
  4. {.push warningAsError[Effect]: on.}
  5. {.experimental: "strictEffects".}
  6. proc fn(a: int, p1, p2: proc()) {.effectsOf: p1.} =
  7. if a == 7:
  8. p1()
  9. if a<0:
  10. raise newException(ValueError, $a)
  11. proc main() {.raises: [ValueError].} =
  12. fn(1, proc()=discard, proc() = raise newException(IOError, "foo"))
  13. main()
  14. # bug #19159
  15. import macros
  16. func mkEnter() =
  17. template helper =
  18. discard
  19. when defined pass:
  20. helper()
  21. else:
  22. let ast = getAst(helper())
  23. # bug #6559
  24. type
  25. SafeFn = proc (): void {. raises: [] }
  26. proc ok() {. raises: [] .} = discard
  27. proc fail() {. raises: [] .}
  28. let f1 : SafeFn = ok
  29. let f2 : SafeFn = fail
  30. proc fail() = discard
  31. f1()
  32. f2()
  33. import std/json
  34. # bug #22254
  35. proc senri(a, b: seq[JsonNode]) {.raises: [].} = discard a == b
  36. # bug #22253
  37. proc serika() {.raises: [].} = discard default(JsonNode) == nil
  38. senri(@[newJBool(true)], @[newJBool(false)])
  39. serika()