Skip to content

fix: report single-member required xor groups as missing - #628

Open
Solaris-star wants to merge 1 commit into
alecthomas:masterfrom
Solaris-star:fix/516-xor-required-and
Open

fix: report single-member required xor groups as missing#628
Solaris-star wants to merge 1 commit into
alecthomas:masterfrom
Solaris-star:fix/516-xor-required-and

Conversation

@Solaris-star

Copy link
Copy Markdown

Summary

When a required flag is in an xor group with optional alternatives, an empty parse previously reported no missing flags if the group only contributed a single required summary (len(flags) > 1 gate).

That made cases like:

Hello string `xor:"hello" required:""`
One   string `xor:"hello" and:"two"`
Two   string `and:"two"`

accept Parse([]string{}) without error (#516).

Fix

In checkMissingFlags, report required xor groups when no member is set even if only one required summary is present (len(flags) >= 1).

Test plan

  • go test .
  • New TestXorAndRequiredIssue516
  • Existing xor/and required tests still pass

Fixes #516

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

xor, required and and don't work together

1 participant