Skip to content

Instantly share code, notes, and snippets.

View geekrelief's full-sized avatar
🤖

Don-Duong Quach geekrelief

🤖
View GitHub Profile
@geekrelief
geekrelief / macro_nilable.nim
Created January 22, 2022 19:34
Nim: Check if a type is nilable in a macro.
import std/[ macros, strformat ]
proc parseParts(x: NimNode): seq[NimNode]
proc parseDotExpr(x: NimNode): seq[NimNode] =
result.add parseParts(x[0])
result.add x
proc parseBracketExpr(x: NimNode): seq[NimNode] =
result.add parseParts(x[0])