Ensure channels don't leak exception effects (#25318)

The forward declarations cause `Exception` to be inferred - also,
`llrecv` is an internal implementation detail and the type of the
received item is controlled by generics, thus the ValueError raised
there seems out of place for the generic api.
This commit is contained in:
Jacek Sieka
2025-12-01 22:59:26 +01:00
committed by GitHub
parent a773178e2b
commit 91febf1f4c
13 changed files with 64 additions and 45 deletions

View File

@@ -15,6 +15,7 @@
# we don't use refcounts because that's a behaviour
# the programmer may not want
{.push raises: [], gcsafe.}
proc dataPointer(a: PGenericSeq, elemAlign: int): pointer =
cast[pointer](cast[int](a) +% align(GenericSeqSize, elemAlign))
@@ -103,7 +104,7 @@ proc toNimStr(str: cstring, len: int): NimString {.compilerproc.} =
copyMem(addr(result.data), str, len)
result.data[len] = '\0'
proc toOwnedCopy(src: NimString): NimString {.inline.} =
proc toOwnedCopy(src: NimString): NimString {.inline, raises: [].} =
## Expects `src` to be not nil and initialized (len and terminating zero set)
result = rawNewStringNoInit(src.len)
result.len = src.len
@@ -149,7 +150,7 @@ proc copyStringRC1(src: NimString): NimString {.compilerRtl.} =
if (src.reserved and strlitFlag) != 0:
result.reserved = (result.reserved and not strlitFlag) or seqShallowFlag
proc copyDeepString(src: NimString): NimString {.inline.} =
proc copyDeepString(src: NimString): NimString {.inline, raises: [].} =
if src != nil:
result = toOwnedCopy(src)
@@ -358,3 +359,4 @@ func capacity*[T](self: seq[T]): int {.inline.} =
let sek = cast[PGenericSeq](self)
result = if sek != nil: sek.space else: 0
{.pop.}