Skip to content

Commit

Permalink
macros: distinct literals (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnetheduck authored Sep 27, 2024
1 parent 9501d3d commit b7b5969
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion stew/shims/macros.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import
std/[macros, tables, hashes]
std/[hashes, macros, tables, typetraits]

export
macros
Expand Down Expand Up @@ -395,6 +395,11 @@ proc newLitFixed*(arg: tuple): NimNode {.compileTime.} =
for a,b in arg.fieldPairs:
result.add nnkExprColonExpr.newTree(newIdentNode(a), newLitFixed(b))

proc newLitFixed*(arg: distinct): NimNode {.compileTime.} =
result = newLitFixed distinctBase(arg)
var typ = getTypeInst(typeof(arg))[1]
result = newCall(typ,result)

iterator typedParams*(n: NimNode, skip = 0): (NimNode, NimNode) =
let params = n[3]
for i in (1 + skip) ..< params.len:
Expand Down

0 comments on commit b7b5969

Please sign in to comment.