From 90ce6f7eea6e08b4ff3774e8d87543237517167e Mon Sep 17 00:00:00 2001 From: George Lemon Date: Thu, 6 Jun 2024 09:24:59 +0300 Subject: [PATCH] update Signed-off-by: George Lemon --- src/voodoo/extensibles.nim | 6 +++++- tests/test2.nim | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/voodoo/extensibles.nim b/src/voodoo/extensibles.nim index 3d23819..014bebc 100644 --- a/src/voodoo/extensibles.nim +++ b/src/voodoo/extensibles.nim @@ -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. diff --git a/tests/test2.nim b/tests/test2.nim index 31ecd79..7e01cca 100644 --- a/tests/test2.nim +++ b/tests/test2.nim @@ -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 \ No newline at end of file +assert compiles Cardinal.east +assert compiles Cardinal.unknown \ No newline at end of file