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 Apr 27, 2024
1 parent eb3aa70 commit 9e38e75
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 @@ -1165,7 +1165,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 9e38e75

Please sign in to comment.