Unchecked assign case object discriminator#117
Conversation
|
the way to really fix this is slightly more complex: one needs to create a "flat" object to hold the union of all fields across all branches, then parse the command line into those objects, then when parsing is done, construct the case object from the flat object picking out the right fields. It's a bit of a mess but the only correct way to do it really with a single parsing pass. |
|
in particular, consider if you have a case object on branch A and one of the fields is a string/seq/ref and is currently assigned - when switching to branch B, those fields need to be destroyed and afair this does not work correctly under orc/arc, which is why the syntax was .. discouraged. |
|
Given this (AFAICT) has the same behavior as |
Fixes #9
{.cast(uncheckedAssign).}around case object field discriminator assignment. This should behave the same as-d:nimOldCaseObjects.parseCmdArg(type enum, string): enumincludes the first letter in the normalization. So it's consistent with the config argument parsing. I checked and it's not being used in status-im, vac, codex, waku, and it's unlikely to break user code since the enum would need to contain elements such as "Foobar" and "foobar", and then it could not be used as a config argument anyway.-d:nimOldCaseObjectsis no longer needed in Nim >= 2.0-d:nimOldCaseObjectsbecause fix #19266; allow reassign discriminant field nim-lang/Nim#19567 was never backported.