Zac-HD/shed

Bug in new `len()` refactor

Zac-HD opened this issue · 2 comments

ls = [1, 2, 3]
maybe_num = None

num = maybe_num or len(ls)

In this case dropping the len() is incorrect; there are presumably other similar cases still latent. CC @jakkdl

oh interesting, I had not considered this usage (and pretty much never use it myself). Yeah currently it will strip all len/bool inside BoolOps, but that's clearly not correct here - so should only strip len/bool if inside BoolOp that's inside an if or similar.

Added a fix to #56, it rewrites the logic enough that I didn't wanna do it in a separate PR.