Skip to content

Commit

Permalink
fixes #23129; fixes generated hooks raise unlisted Exception, which n…
Browse files Browse the repository at this point in the history
…ever raise (#23195)

fixes #23129

(cherry picked from commit 62c5b8b)
  • Loading branch information
ringabout authored and narimiran committed Jul 9, 2024
1 parent be99f2f commit 83455cf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
7 changes: 6 additions & 1 deletion compiler/liftdestructors.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
16 changes: 16 additions & 0 deletions tests/effects/thooks.nim
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 83455cf

Please sign in to comment.