From 0693e0207f7f817c9dd02191c158d345a1139032 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Wed, 18 Feb 2026 19:36:55 +0800 Subject: [PATCH] fix #25508; disallow 'void' as a field type --- compiler/semtypes.nim | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index c6ed5e77dc..62b63eb891 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -528,7 +528,10 @@ proc semAnonTuple(c: PContext, n: PNode, prev: PType): PType = result = newOrPrevType(tyTuple, prev, c) for it in n: let t = semTypeNode(c, it, nil) - addSonSkipIntLitChecked(c, result, t, it, c.idgen) + if t != nil and t.kind == tyVoid: + localError(c.config, it.info, "'void' is not allowed as a field type") + else: + addSonSkipIntLitChecked(c, result, t, it, c.idgen) proc firstRange(config: ConfigRef, t: PType): PNode = if t.skipModifier().kind in tyFloat..tyFloat64: @@ -565,6 +568,9 @@ proc semTuple(c: PContext, n: PNode, prev: PType): PType = else: localError(c.config, a.info, errTypeExpected) typ = errorType(c) + if typ != nil and typ.kind == tyVoid: + localError(c.config, a.info, "'void' is not allowed as a field type") + typ = errorType(c) for j in 0.. 0: c.getCurrOwner else: rectype.sym for i in 0..