Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where Flags.remove could set flags in addition to unsetting them #3777

Merged
merged 1 commit into from
Jul 5, 2021

Conversation

redvers
Copy link
Contributor

@redvers redvers commented Jul 5, 2021

Note - I've written a test-suite to cover 90% of this module but it's dependent on a second PR that I'm about to open.

Test coverage is in there.

@SeanTAllen
Copy link
Member

The title of the PR will appear in the changelog, can you change it to something more "end user friendly"?

@SeanTAllen
Copy link
Member

FYI a "Fixes X" should appear in general at the end of the commit comment.

@SeanTAllen SeanTAllen added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Jul 5, 2021
@ponylang-main
Copy link
Contributor

Hi @redvers,

The changelog - fixed label was added to this pull request; all PRs with a changelog label need to have release notes included as part of the PR. If you haven't added release notes already, please do.

Release notes are added by creating a uniquely named file in the .release-notes directory. We suggest you call the file 3777.md to match the number of this pull request.

The basic format of the release notes (using markdown) should be:

## Title

End user description of changes, why it's important,
problems it solves etc.

If a breaking change, make sure to include 1 or more
examples what code would look like prior to this change
and how to update it to work after this change.

Thanks.

@SeanTAllen
Copy link
Member

I'd rather see the test coverage as either part of this PR or for the test coverage PR to come first and this to follow. There's no test here to show this works and doesn't break other things.

I'd be in favor of adding the test coverage to this PR.

@SeanTAllen SeanTAllen added the do not merge This PR should not be merged at this time label Jul 5, 2021
@redvers
Copy link
Contributor Author

redvers commented Jul 5, 2021

So, my test suite uses the new create() constructor throughout... so won't work unless that change is also merged.

eg:

    // Mutable Bitwise Operator: without
                                                           // 0b0011
                                                           // 0b0101 without
    h.assert_true(set0011.without(set0101) == _TestFlagsFlags(0b0010))
                                                           // 0b0101
                                                           // 0b0011 without
    h.assert_true(set0101.without(set0011) == _TestFlagsFlags(0b0100))


    // Mutable Operator: union
    t = set0011.clone()              //0b0011
    t.union(set0101)                 //0b0101
    h.assert_true(t == _TestFlagsFlags(0b0111))

    // a.union(b) == b.union(a)
    t = set0101.clone()              //0b0101
    t.union(set0011)                 //0b0011
    h.assert_true(t == _TestFlagsFlags(0b0111))

Should I put it all in one then?

@SeanTAllen
Copy link
Member

Is the bug possible without the create change?

@redvers
Copy link
Contributor Author

redvers commented Jul 5, 2021

I'll re-write the test suite to use the other format and push.

@SeanTAllen SeanTAllen changed the title Fixes Issue#3776. Corrected the implementation for Flags.remove() Fix bug where Flags.remove could turn on flags in addition to removing/turning them off Jul 5, 2021
@SeanTAllen SeanTAllen changed the title Fix bug where Flags.remove could turn on flags in addition to removing/turning them off Fix bug where Flags.remove could set flags in addition to unsetting them Jul 5, 2021
@SeanTAllen
Copy link
Member

@redvers can you update the commit comment to be:

Fix bug where Flags.remove could set flags in addition to unsetting them

Flags.remove when given a flag to remove that wasn't currently present in the set, would turn the flag on. 
It should only be turning flags off, not turning them on.

Closes #3776 

Release notes of

## Fix bug where Flags.remove could set flags in addition to unsetting them

Flags.remove when given a flag to remove that wasn't currently present in the set, would turn the flag on. 
It should only be turning flags off, not turning them on.

would be good as well.

@SeanTAllen
Copy link
Member

SeanTAllen commented Jul 5, 2021

These two

as tests would be good enough coverage for me to push this update through.

We don't need a full suite. Merely ones showing the two basic cases we expect for remove and them passing with this change.

@SeanTAllen
Copy link
Member

@redvers I can do the commit comment change on squash/merge.

@redvers
Copy link
Contributor Author

redvers commented Jul 5, 2021

If it's okay with you I'd like to do the squash. I want to make sure I understand the full-workflow so any future work will require less work from the maintainers.

Flags.remove when given a flag to remove that wasn't currently present in the set, would turn the flag on.
It should only be turning flags off, not turning them on.

Closes ponylang#3776
@SeanTAllen
Copy link
Member

@redvers fine with me.

@redvers
Copy link
Contributor Author

redvers commented Jul 5, 2021

Okay - so I think pending CI - I think that's everything? Yay!

@SeanTAllen SeanTAllen removed the do not merge This PR should not be merged at this time label Jul 5, 2021
@SeanTAllen SeanTAllen merged commit 9f136ba into ponylang:main Jul 5, 2021
github-actions bot pushed a commit that referenced this pull request Jul 5, 2021
github-actions bot pushed a commit that referenced this pull request Jul 5, 2021
@redvers redvers mentioned this pull request Jul 7, 2021
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants