Skip to content

Fix formatting of multi-bit flags with partial overlap#316

Merged
KodrAus merged 2 commits intobitflags:mainfrom
KodrAus:fix/multi-bit-flag-fmt
Mar 16, 2023
Merged

Fix formatting of multi-bit flags with partial overlap#316
KodrAus merged 2 commits intobitflags:mainfrom
KodrAus:fix/multi-bit-flag-fmt

Conversation

@KodrAus
Copy link
Copy Markdown
Member

@KodrAus KodrAus commented Mar 16, 2023

Fixes #315

cc @mxk

I've added a repro for the bug reported here: #310 (comment)

It looks like we'll need to tweak the iter_names method to make sure we include any remaining bits when they overlap, but don't complete, a multi-bit flag.

@KodrAus
Copy link
Copy Markdown
Member Author

KodrAus commented Mar 16, 2023

Ok, it looks like the fix for this was fairly straightfoward: we were using the flags themselves to try mask out any bits that don't correspond to a valid flag, but in this example the extra bits do correspond to part of a flag. So we'd mask them out without printing anything for them.

Using the iterator as the source of these bits ensures anything not printed by name will get printed as a hex number.

@KodrAus KodrAus merged commit af44dcc into bitflags:main Mar 16, 2023
@KodrAus KodrAus deleted the fix/multi-bit-flag-fmt branch March 16, 2023 03:30
@mxk
Copy link
Copy Markdown

mxk commented Mar 16, 2023

Thanks for getting this fixed!

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.

Display missing extra bits for multi-bit flags

2 participants