fixes #23129; fixes generated hooks raise unlisted Exception, which never raise (#23195)

fixes #23129

(cherry picked from commit 62c5b8b287)
This commit is contained in:
ringabout
2024-01-11 14:47:33 +08:00
committed by narimiran
parent be99f2fed8
commit 83455cf1d5
2 changed files with 22 additions and 1 deletions

View File

@@ -1173,7 +1173,12 @@ proc produceSym(g: ModuleGraph; c: PContext; typ: PType; kind: TTypeAttachedOp;
# bug #19205: Do not forget to also copy the hidden type field:
genTypeFieldCopy(a, typ, result.ast[bodyPos], d, src)
if not a.canRaise: incl result.flags, sfNeverRaises
if not a.canRaise:
incl result.flags, sfNeverRaises
result.ast[pragmasPos] = newNodeI(nkPragma, info)
result.ast[pragmasPos].add newTree(nkExprColonExpr,
newIdentNode(g.cache.getIdent("raises"), info), newNodeI(nkBracket, info))
completePartialOp(g, idgen.module, typ, kind, result)

16
tests/effects/thooks.nim Normal file
View File

@@ -0,0 +1,16 @@
discard """
matrix: "--warningAsError:Effect"
"""
import std/isolation
# bug #23129
type
Thing = object
x: string
proc send(x: string) =
let wrapper = Thing(x: x)
discard isolate(wrapper)
send("la")