diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2023-08-11 22:16:58 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-11 22:16:58 +0800 |
commit | 72bc72bf9ea470603420a0b56f63dad063f808a9 (patch) | |
tree | 4ad1124693170c390bcd31978f7d6f7806a26933 | |
parent | 277393d0f1c06c422afb6fae581069960609b730 (diff) | |
download | Nim-72bc72bf9ea470603420a0b56f63dad063f808a9.tar.gz |
refactor `result = default(...)` into object construction (#22455)
-rw-r--r-- | compiler/semtypinst.nim | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim index aef1e0374..e3c8c1c0a 100644 --- a/compiler/semtypinst.nim +++ b/compiler/semtypinst.nim @@ -96,9 +96,7 @@ proc initLayeredTypeMap*(pt: TIdTable): LayeredIdTable = copyIdTable(result.topLayer, pt) proc newTypeMapLayer*(cl: var TReplTypeVars): LayeredIdTable = - result = LayeredIdTable() - result.nextLayer = cl.typeMap - result.topLayer = initIdTable() + result = LayeredIdTable(nextLayer: cl.typeMap, topLayer: initIdTable()) proc lookup(typeMap: LayeredIdTable, key: PType): PType = result = nil @@ -685,13 +683,9 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType = proc initTypeVars*(p: PContext, typeMap: LayeredIdTable, info: TLineInfo; owner: PSym): TReplTypeVars = - result = default(TReplTypeVars) - result.symMap = initIdTable() - result.localCache = initIdTable() - result.typeMap = typeMap - result.info = info - result.c = p - result.owner = owner + result = TReplTypeVars(symMap: initIdTable(), + localCache: initIdTable(), typeMap: typeMap, + info: info, c: p, owner: owner) proc replaceTypesInBody*(p: PContext, pt: TIdTable, n: PNode; owner: PSym, allowMetaTypes = false, |