summary refs log tree commit diff stats
path: root/compiler/semobjconstr.nim
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2022-11-17 09:38:50 +0800
committerGitHub <noreply@github.com>2022-11-17 09:38:50 +0800
commit1707bc4a992bc966a7439facb9ee819023c22f77 (patch)
tree34faa9fea4f0734e63225bfc0f496aca8df94d7c /compiler/semobjconstr.nim
parentcdbf5b469949366d56f1eb2dbc7721eaf0cbc218 (diff)
downloadNim-1707bc4a992bc966a7439facb9ee819023c22f77.tar.gz
fixes #20856; store defaults directly (#20859)
* fixes #20856; store defaults directly

* fixes

* fixes

* check

* fixes
Diffstat (limited to 'compiler/semobjconstr.nim')
-rw-r--r--compiler/semobjconstr.nim6
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/semobjconstr.nim b/compiler/semobjconstr.nim
index 7f76dbee9..206602677 100644
--- a/compiler/semobjconstr.nim
+++ b/compiler/semobjconstr.nim
@@ -387,8 +387,7 @@ proc defaultConstructionError(c: PContext, t: PType, info: TLineInfo) =
 proc semObjConstr(c: PContext, n: PNode, flags: TExprFlags; expectedType: PType = nil): PNode =
   var t = semTypeNode(c, n[0], nil)
   result = newNodeIT(nkObjConstr, n.info, t)
-  result.add newNodeIT(nkType, n.info, t) #This will contain the default values to be added in transf
-  for i in 1..<n.len:
+  for i in 0..<n.len:
     result.add n[i]
 
   if t == nil:
@@ -421,7 +420,6 @@ proc semObjConstr(c: PContext, n: PNode, flags: TExprFlags; expectedType: PType
   # branches will be reported as an error):
   var constrCtx = initConstrContext(t, result)
   let (initResult, defaults) = semConstructTypeAux(c, constrCtx, flags)
-  result[0].sons.add defaults
   var hasError = false # needed to split error detect/report for better msgs
 
   # It's possible that the object was not fully initialized while
@@ -457,6 +455,8 @@ proc semObjConstr(c: PContext, n: PNode, flags: TExprFlags; expectedType: PType
       hasError = true
       break
 
+  result.sons.add defaults
+
   if initResult == initFull:
     incl result.flags, nfAllFieldsSet