properly fold constants for dynlib pragma (#22575)

fixes #12929

(cherry picked from commit 6b955ac4af)
This commit is contained in:
metagn
2023-08-28 22:41:18 +03:00
committed by narimiran
parent d49d7ba90c
commit 7c44af4e22

View File

@@ -330,7 +330,7 @@ proc expectDynlibNode(c: PContext, n: PNode): PNode =
# {.dynlib: myGetProcAddr(...).}
result = c.semExpr(c, n[1])
if result.kind == nkSym and result.sym.kind == skConst:
result = result.sym.astdef # look it up
result = c.semConstExpr(c, result) # fold const
if result.typ == nil or result.typ.kind notin {tyPointer, tyString, tyProc}:
localError(c.config, n.info, errStringLiteralExpected)
result = newEmptyStrNode(c, n)