Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: George Lemon <[email protected]>
  • Loading branch information
georgelemon committed Jun 6, 2024
1 parent f87fc79 commit 90ce6f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/voodoo/extensibles.nim
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ macro extendEnum*(x: untyped, fields: untyped) =
add otherFields, f
else:
error("Voodoo - Invalid enum extension. Expects either `nnkAsgn`, or `nnkIdent`")
ExtendableEnums[$x] = otherFields
if ExtendableEnums.hasKey($x):
for xfield in otherFields:
add ExtendableEnums[$x], xfield
else:
ExtendableEnums[$x] = otherFields

template extendCase*(fieldNode: untyped, branchesNode: untyped) =
## Extend an object variant by adding new branches.
Expand Down
8 changes: 7 additions & 1 deletion tests/test2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ extendEnum Cardinal:
south
east

extendEnum Cardinal:
unknown

import ./extensibleModule

assert compiles Cardinal.north
assert compiles Cardinal.west
assert compiles Cardinal.south
assert compiles Cardinal.east
assert compiles Cardinal.east
assert compiles Cardinal.unknown

0 comments on commit 90ce6f7

Please sign in to comment.