diff options
Diffstat (limited to 'compiler/semmagic.nim')
-rw-r--r-- | compiler/semmagic.nim | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/compiler/semmagic.nim b/compiler/semmagic.nim index 6e5563d69..77286393e 100644 --- a/compiler/semmagic.nim +++ b/compiler/semmagic.nim @@ -353,9 +353,17 @@ proc magicsAfterOverloadResolution(c: PContext, n: PNode, localError(c.config, n.info, "cannot evaluate 'sizeof' because its type is not defined completely, type: " & n[1].typ.typeToString) result = n of mAlignOf: - result = newIntNode(nkIntLit, getAlign(c.config, n[1].typ)) - result.info = n.info - result.typ = n.typ + # this is 100% analog to mSizeOf, could be made more dry. + let align = getAlign(c.config, n[1].typ) + if align == szUnknownSize: + result = n + elif align >= 0: + result = newIntNode(nkIntLit, align) + result.info = n.info + result.typ = n.typ + else: + localError(c.config, n.info, "cannot evaluate 'alignof' because its type is not defined completely, type: " & n[1].typ.typeToString) + result = n of mOffsetOf: var dotExpr: PNode |