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

Flags.remove mutating to an incorrect value. #3776

Closed
redvers opened this issue Jul 5, 2021 · 2 comments
Closed

Flags.remove mutating to an incorrect value. #3776

redvers opened this issue Jul 5, 2021 · 2 comments

Comments

@redvers
Copy link
Contributor

redvers commented Jul 5, 2021

    t = set0011.clone()              //0b0011
    t.remove(set0101)                //0b0101
    h.assert_true(t == _TestFlagsFlags(0b0010))

The test fails as it's mutating to 0b0110.

PR incoming.

@SeanTAllen
Copy link
Member

Do you have a reproducible example?

@SeanTAllen
Copy link
Member

Example:

use "collections"

actor Main
  new create(env: Env) =>
    let a = _TestFlagsFlags.>set(_TestFlagA)
    let b = recover val _TestFlagsFlags.>set(_TestFlagB) end
  
    if not a(_TestFlagA) then
      env.out.print("pre Bad 1")
    end
    
    if a(_TestFlagB) then
      env.out.print("pre Bad 2")
    end
    
    if a(_TestFlagC) then
      env.out.print("pre Bad 3")
    end
    
    if a(_TestFlagD) then
      env.out.print("pre Bad 4")
    end

    a.remove(b)
    
    if not a(_TestFlagA) then
      env.out.print("Bad 1")
    end
    
    if a(_TestFlagB) then
      env.out.print("Bad 2")
    end
    
    if a(_TestFlagC) then
      env.out.print("Bad 3")
    end
    
    if a(_TestFlagD) then
      env.out.print("Bad 4")
    end

type _TestFlagsFlags is Flags[(_TestFlagA|_TestFlagB|_TestFlagC|_TestFlagD),U8]
primitive _TestFlagA fun value(): U8 => 1
primitive _TestFlagB fun value(): U8 => 2
primitive _TestFlagC fun value(): U8 => 4
primitive _TestFlagD fun value(): U8 => 8

redvers added a commit to redvers/ponyc that referenced this issue Jul 5, 2021
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
redvers added a commit to redvers/ponyc that referenced this issue Jul 5, 2021
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
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

No branches or pull requests

2 participants