properly fold constants for dynlib pragma (#22575)

fixes #12929
This commit is contained in:
metagn
2023-08-28 22:41:18 +03:00
committed by GitHub
parent 3de8d75513
commit 6b955ac4af

View File

@@ -333,7 +333,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)