Skip to content

Commit

Permalink
Merge branch 'devel' into pr_destructor_hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout authored Feb 19, 2025
2 parents 4156470 + 510ac84 commit 491059a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
6 changes: 5 additions & 1 deletion compiler/pragmas.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1318,8 +1318,12 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int,
pragmaProposition(c, it)
of wEnsures:
pragmaEnsures(c, it)
of wEnforceNoRaises, wQuirky:
of wEnforceNoRaises:
sym.flags.incl sfNeverRaises
of wQuirky:
sym.flags.incl sfNeverRaises
if sym.kind in {skProc, skMethod, skConverter, skFunc, skIterator}:
sym.options.incl optQuirky
of wSystemRaisesDefect:
sym.flags.incl sfSystemRaisesDefect
of wVirtual:
Expand Down
5 changes: 4 additions & 1 deletion lib/system/arc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ else:
template count(x: Cell): untyped =
x.rc shr rcShift

when not defined(nimHasQuirky):
{.pragma: quirky.}

proc nimNewObj(size, alignment: int): pointer {.compilerRtl.} =
let hdrSize = align(sizeof(RefHeader), alignment)
let s = size + hdrSize
Expand Down Expand Up @@ -190,7 +193,7 @@ proc nimRawDispose(p: pointer, alignment: int) {.compilerRtl.} =
template `=dispose`*[T](x: owned(ref T)) = nimRawDispose(cast[pointer](x), T.alignOf)
#proc dispose*(x: pointer) = nimRawDispose(x)

proc nimDestroyAndDispose(p: pointer) {.compilerRtl, raises: [].} =
proc nimDestroyAndDispose(p: pointer) {.compilerRtl, quirky, raises: [].} =
let rti = cast[ptr PNimTypeV2](p)
if rti.destructor != nil:
cast[DestructorProc](rti.destructor)(p)
Expand Down
16 changes: 16 additions & 0 deletions tests/arc/tvalgrind.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
discard """
cmd: "nim c --mm:orc -d:useMalloc $file"
valgrind: "true"
"""

import std/streams


proc foo() =
var name = newStringStream("2r2")
raise newException(ValueError, "sh")

try:
foo()
except:
discard

0 comments on commit 491059a

Please sign in to comment.