Skip to content

Commit 90ce6f7

Browse files
committed
update
Signed-off-by: George Lemon <[email protected]>
1 parent f87fc79 commit 90ce6f7

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/voodoo/extensibles.nim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ macro extendEnum*(x: untyped, fields: untyped) =
2525
add otherFields, f
2626
else:
2727
error("Voodoo - Invalid enum extension. Expects either `nnkAsgn`, or `nnkIdent`")
28-
ExtendableEnums[$x] = otherFields
28+
if ExtendableEnums.hasKey($x):
29+
for xfield in otherFields:
30+
add ExtendableEnums[$x], xfield
31+
else:
32+
ExtendableEnums[$x] = otherFields
2933

3034
template extendCase*(fieldNode: untyped, branchesNode: untyped) =
3135
## Extend an object variant by adding new branches.

tests/test2.nim

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ extendEnum Cardinal:
55
south
66
east
77

8+
extendEnum Cardinal:
9+
unknown
10+
811
import ./extensibleModule
912

13+
assert compiles Cardinal.north
14+
assert compiles Cardinal.west
1015
assert compiles Cardinal.south
11-
assert compiles Cardinal.east
16+
assert compiles Cardinal.east
17+
assert compiles Cardinal.unknown

0 commit comments

Comments
 (0)