Skip to content

Commit 4703a51

Browse files
committed
Ensure channels don't leak exception effects
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.
1 parent 6656084 commit 4703a51

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/system/channels_builtin.nim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@
138138
## localChannelExample() # "Hello from the main thread!"
139139
## ```
140140

141+
{.push raises: [], gcsafe.}
142+
141143
when not declared(ThisIsSystem):
142144
{.error: "You must not import this module explicitly".}
143145

@@ -390,7 +392,7 @@ proc llRecv(q: PRawChannel, res: pointer, typ: PNimType) =
390392
q.ready = false
391393
if typ != q.elemType:
392394
releaseSys(q.lock)
393-
raise newException(ValueError, "cannot receive message of wrong type")
395+
raiseAssert "cannot receive message of wrong type"
394396
rawRecv(q, res, typ)
395397
if q.maxItems > 0 and q.count == q.maxItems - 1:
396398
# Parent thread is awaiting in send. Wake it up.
@@ -455,3 +457,5 @@ proc ready*[TMsg](c: var Channel[TMsg]): bool =
455457
## new messages.
456458
var q = cast[PRawChannel](addr(c))
457459
result = q.ready
460+
461+
{.pop.}

0 commit comments

Comments
 (0)