12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- discard """
- action: compile
- """
- {.push warningAsError[Effect]: on.}
- {.experimental: "strictEffects".}
- proc fn(a: int, p1, p2: proc()) {.effectsOf: p1.} =
- if a == 7:
- p1()
- if a<0:
- raise newException(ValueError, $a)
- proc main() {.raises: [ValueError].} =
- fn(1, proc()=discard, proc() = raise newException(IOError, "foo"))
- main()
- # bug #19159
- import macros
- func mkEnter() =
- template helper =
- discard
- when defined pass:
- helper()
- else:
- let ast = getAst(helper())
- # bug #6559
- type
- SafeFn = proc (): void {. raises: [] }
- proc ok() {. raises: [] .} = discard
- proc fail() {. raises: [] .}
- let f1 : SafeFn = ok
- let f2 : SafeFn = fail
- proc fail() = discard
- f1()
- f2()
- import std/json
- # bug #22254
- proc senri(a, b: seq[JsonNode]) {.raises: [].} = discard a == b
- # bug #22253
- proc serika() {.raises: [].} = discard default(JsonNode) == nil
- senri(@[newJBool(true)], @[newJBool(false)])
- serika()
|