Skip to content

Commit

Permalink
fix: add type checking for enum variant in toRON generator
Browse files Browse the repository at this point in the history
Ensures that enum variants are strings in the RON generator and provides a clear error message when they are not. This prevents potential issues with non-string variants being incorrectly converted.
  • Loading branch information
HeitorAugustoLN committed Jan 8, 2025
1 parent 97b6b3c commit d283378
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/generators.nix
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@
},\n${indent startIndent})"
else
throw "lib.cosmic.generators.toRON: enum type must have a list of values."
else if builtins.isString value.variant then
value.variant
else
toString value.variant
throw "lib.cosmic.generators.toRON: enum type variant must be a string value."
else
throw "lib.cosmic.generators.toRON: enum type must have a variant."
else if value.__type == "map" then
Expand Down

0 comments on commit d283378

Please sign in to comment.