@@ -206,14 +206,14 @@ proc replaceNodes(ast: NimNode): NimNode =
206
206
proc inspect(node: NimNode): NimNode =
207
207
case node.kind:
208
208
of nnkIdent, nnkSym:
209
- return ident($ node)
209
+ result = ident($ node)
210
210
of nnkEmpty, nnkLiterals:
211
- return node
211
+ result = node
212
212
else :
213
213
var rTree = node.kind.newTree()
214
214
for child in node:
215
215
rTree.add inspect(child)
216
- return rTree
216
+ result = rTree
217
217
result = inspect(ast)
218
218
219
219
macro distinctBase* (T: typedesc , recursive: static [bool ] = false ): untyped =
@@ -229,24 +229,24 @@ macro distinctBase*(T: typedesc, recursive: static[bool] = false): untyped =
229
229
230
230
let typeNode = getTypeImpl(T)
231
231
expectKind(typeNode, nnkBracketExpr)
232
- if $ typeNode[0 ] != " typeDesc " :
232
+ if typeNode[0 ].typeKind != ntyTypeDesc :
233
233
error " expected typeDesc, got " & $ typeNode[0 ]
234
234
var typeSym = typeNode[1 ]
235
235
if not recursive:
236
236
let impl = getTypeImpl(typeSym)
237
- if $ impl.typeKind != " ntyDistinct" :
237
+ if impl.typeKind != ntyDistinct:
238
238
error " type is not distinct"
239
239
typeSym = getTypeInst(impl[0 ])
240
240
else :
241
241
while true :
242
242
let impl = getTypeImpl(typeSym)
243
- if $ impl.typeKind != " ntyDistinct" :
243
+ if impl.typeKind != ntyDistinct:
244
244
typeSym = impl
245
245
break
246
- typeSym= getTypeInst(impl[0 ])
246
+ typeSym = getTypeInst(impl[0 ])
247
247
typeSym.replaceNodes
248
248
249
- proc distinctBase* [T](a: T, recursive: static [bool ] = false): auto =
249
+ func distinctBase* [T](a: T, recursive: static [bool ] = false): auto {.inline.} =
250
250
## converts a distinct variable to it's original type
251
251
runnableExamples:
252
252
type T = distinct int
0 commit comments