Skip to content

Commit a183d93

Browse files
committed
address reviewer comments
1 parent 8651901 commit a183d93

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/pure/sugar.nim

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,14 @@ proc replaceNodes(ast: NimNode): NimNode =
206206
proc inspect(node: NimNode): NimNode =
207207
case node.kind:
208208
of nnkIdent, nnkSym:
209-
return ident($node)
209+
result = ident($node)
210210
of nnkEmpty, nnkLiterals:
211-
return node
211+
result = node
212212
else:
213213
var rTree = node.kind.newTree()
214214
for child in node:
215215
rTree.add inspect(child)
216-
return rTree
216+
result = rTree
217217
result = inspect(ast)
218218

219219
macro distinctBase*(T: typedesc, recursive: static[bool] = false): untyped =
@@ -229,24 +229,24 @@ macro distinctBase*(T: typedesc, recursive: static[bool] = false): untyped =
229229

230230
let typeNode = getTypeImpl(T)
231231
expectKind(typeNode, nnkBracketExpr)
232-
if $typeNode[0] != "typeDesc":
232+
if typeNode[0].typeKind != ntyTypeDesc:
233233
error "expected typeDesc, got " & $typeNode[0]
234234
var typeSym = typeNode[1]
235235
if not recursive:
236236
let impl = getTypeImpl(typeSym)
237-
if $impl.typeKind != "ntyDistinct":
237+
if impl.typeKind != ntyDistinct:
238238
error "type is not distinct"
239239
typeSym = getTypeInst(impl[0])
240240
else:
241241
while true:
242242
let impl = getTypeImpl(typeSym)
243-
if $impl.typeKind != "ntyDistinct":
243+
if impl.typeKind != ntyDistinct:
244244
typeSym = impl
245245
break
246-
typeSym=getTypeInst(impl[0])
246+
typeSym = getTypeInst(impl[0])
247247
typeSym.replaceNodes
248248

249-
proc distinctBase*[T](a: T, recursive: static[bool] = false): auto =
249+
func distinctBase*[T](a: T, recursive: static[bool] = false): auto {.inline.} =
250250
## converts a distinct variable to it's original type
251251
runnableExamples:
252252
type T = distinct int

0 commit comments

Comments
 (0)