mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-30 01:44:37 +00:00
* fixes #17369 * megatest is green for --cpu:arm64 * docgen output includes more tags/raises * implemented 'effectsOf' * algorithm.nim: uses new effectsOf annotation * closes #18376 * closes #17475 * closes #13905 * allow effectsOf: [a, b] * added a test case * parameters that are not ours cannot be declared as .effectsOf * documentation * manual: added the 'sort' example * bootstrap with the new better options
45 lines
1.3 KiB
Nim
45 lines
1.3 KiB
Nim
discard """
|
|
cmd: "nim check $file"
|
|
nimout: '''teffects1.nim(22, 28) template/generic instantiation from here
|
|
teffects1.nim(23, 13) Error: can raise an unlisted exception: ref IOError
|
|
teffects1.nim(22, 29) Hint: 'lier' cannot raise 'IO2Error' [XCannotRaiseY]
|
|
teffects1.nim(38, 21) Error: type mismatch: got <proc (x: int): string{.noSideEffect, gcsafe, locks: 0.}> but expected 'MyProcType = proc (x: int): string{.closure.}'
|
|
.raise effects differ'''
|
|
"""
|
|
{.push warningAsError[Effect]: on.}
|
|
type
|
|
TObj {.pure, inheritable.} = object
|
|
TObjB = object of TObj
|
|
a, b, c: string
|
|
|
|
IO2Error = ref object of IOError
|
|
|
|
proc forw: int {. .}
|
|
|
|
proc lier(): int {.raises: [IO2Error].} =
|
|
#[tt.Hint ^ 'lier' cannot raise 'IO2Error' [XCannotRaiseY] ]#
|
|
writeLine stdout, "arg" #[tt.Error
|
|
^ can raise an unlisted exception: ref IOError
|
|
]#
|
|
|
|
proc forw: int =
|
|
raise newException(IOError, "arg")
|
|
|
|
{.push raises: [Defect].}
|
|
|
|
type
|
|
MyProcType* = proc(x: int): string #{.raises: [ValueError, Defect].}
|
|
|
|
proc foo(x: int): string {.raises: [ValueError].} =
|
|
if x > 9:
|
|
raise newException(ValueError, "Use single digit")
|
|
$x
|
|
|
|
var p: MyProcType = foo #[tt.Error
|
|
^
|
|
type mismatch: got <proc (x: int): string{.noSideEffect, gcsafe, locks: 0.}> but expected 'MyProcType = proc (x: int): string{.closure.}'
|
|
|
|
]#
|
|
{.pop.}
|
|
{.pop.}
|