From 03a838b91d580f88d976c774aff3df89c71af6eb Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Fri, 5 Jul 2024 22:53:55 +0800 Subject: [PATCH] fixes #23770; const object variants in the default fields --- compiler/semobjconstr.nim | 53 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/compiler/semobjconstr.nim b/compiler/semobjconstr.nim index 96b2d702dabc..61a794a2ac92 100644 --- a/compiler/semobjconstr.nim +++ b/compiler/semobjconstr.nim @@ -12,6 +12,7 @@ # included from sem.nim from std/sugar import dup +from expanddefaults import caseObjDefaultBranch type ObjConstrContext = object @@ -208,6 +209,46 @@ proc collectBranchFields(c: PContext, n: PNode, discriminatorVal: PNode, "for a branch whose fields have default values.") discard collectMissingCaseFields(c, n[i], constrCtx, @[]) +proc filterDefaultValue(c: PContext, typ: PType, constr: PNode): PNode + +proc filterConstructFields(c: PContext, n: PNode, constr: PNode, pos: var int, defaults: var seq[PNode]) = + case n.kind + of nkRecList: + for i in 0..