diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2022-11-15 00:31:06 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-15 00:31:06 +0800 |
commit | 7f2ff909d9010646c87e04edb8863dbafb98fa6c (patch) | |
tree | 158fe41f69a86685d2166bb7a7d31552e67be7c4 /compiler/semobjconstr.nim | |
parent | 1daf43fb149a784df0b3fd7eb219a31472b13d8c (diff) | |
download | Nim-7f2ff909d9010646c87e04edb8863dbafb98fa6c.tar.gz |
fixes object default fields bugs and add tests (#20839)
* fixes object default fields bugs and add tests * Update compiler/semmagic.nim * Update compiler/sem.nim * Update compiler/sem.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Diffstat (limited to 'compiler/semobjconstr.nim')
-rw-r--r-- | compiler/semobjconstr.nim | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/semobjconstr.nim b/compiler/semobjconstr.nim index 1463ba833..7f76dbee9 100644 --- a/compiler/semobjconstr.nim +++ b/compiler/semobjconstr.nim @@ -326,7 +326,12 @@ proc semConstructFields(c: PContext, n: PNode, constrCtx: var ObjConstrContext, result.status = initUnknown result.defaults.add newTree(nkExprColonExpr, n, field.ast) else: - result.status = initNone + let defaultExpr = defaultNodeField(c, n) + if defaultExpr != nil: + result.status = initUnknown + result.defaults.add newTree(nkExprColonExpr, n, defaultExpr) + else: + result.status = initNone else: internalAssert c.config, false |