You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because I didn't know any better, when I first used BitVec (version 1.0.1) yesterday I called .as_bool() on a particular bit of a BitVec, instead of just evaluating the bit.
Surprisingly, it returned the negated bit value instead of the expected value. Here's a test to demonstrate:
So the filter predicate closure in this case (and many other cases) is |this| this != 0, and the strange (to me) part about this is that it is called $is_zero in the macro. It would make sense to me if it were called either $is_NOT_zero or is_true or bit_is_set or anything along those lines.
Or maybe I completely mis-understand the purpose of as_bool()?
The text was updated successfully, but these errors were encountered:
Hi! I apologize for the long delay; I have had a very stressful winter and have not had the time or energy to check this repository in a timely manner. I'm trying to catch up now.
Okay, so, bitslice[index] already produces a bool; you shouldn't need to change its type. But this is definitely a logic error in funty.
I'll have to fix it in funty 2, since bitvec 1 is going to keep using that. Thank you for bringing it to my attention.
In my case, I was using as_bool() because I'm not familiar with BitVec and some API I'm calling returned BitVec. I wanted to iterate over the bits, so I did .iter(), and then I ended up with a BitRef, and I called as_bool() on that, causing the problem illustrated by the OP.
Because I didn't know any better, when I first used
BitVec
(version 1.0.1) yesterday I called.as_bool()
on a particular bit of aBitVec
, instead of just evaluating the bit.Surprisingly, it returned the negated bit value instead of the expected value. Here's a test to demonstrate:
The code that causes this is part of funty 2.0.0. Unfortunately, I couldn't find an appropriate branch of funty to create a PR.
It looks like this will be fixed in funty 3.0 (its
main
branch seems to be the 3.0 RC1), as the code foras_bool()
forbool
was replaced by this:I do want to mention that the
impl_for
macro reads a bit strange to me, but then again I don't have much experience with macros. It reads like this:Here's one example usage (of many more):
So the filter predicate closure in this case (and many other cases) is
|this| this != 0
, and the strange (to me) part about this is that it is called$is_zero
in the macro. It would make sense to me if it were called either$is_NOT_zero
oris_true
orbit_is_set
or anything along those lines.Or maybe I completely mis-understand the purpose of
as_bool()
?The text was updated successfully, but these errors were encountered: