Fix #22713: Make size unknown for tyForward (#22714)

Close #22713

---------

Co-authored-by: SirOlaf <>
(cherry picked from commit fcf4c1ae17)
This commit is contained in:
SirOlaf
2023-09-17 20:03:43 +02:00
committed by narimiran
parent dc6058fb9b
commit 344feb0dd1
2 changed files with 15 additions and 4 deletions

View File

@@ -433,10 +433,9 @@ proc computeSizeAlign(conf: ConfigRef; typ: PType) =
typ.paddingAtEnd = typ.base.paddingAtEnd
of tyForward:
# is this really illegal recursion, or maybe just unknown?
typ.size = szIllegalRecursion
typ.align = szIllegalRecursion
typ.paddingAtEnd = szIllegalRecursion
typ.size = szUnknownSize
typ.align = szUnknownSize
typ.paddingAtEnd = szUnknownSize
of tyStatic:
if typ.n != nil:

12
tests/pragmas/t22713.nim Normal file
View File

@@ -0,0 +1,12 @@
import std/macros
template myPragma(x: int) {.pragma.}
type
A = object
x: int64
B {.myPragma(sizeof(A)).} = object
doAssert B.getCustomPragmaVal(myPragma) == 8