I believe this is a different problem from the linked github issue. Right now PyTeal has a strict requirement that a scratch slot cannot be loaded unless it has a value stored in it first, and I believe that’s the problem here.
If you were to add bitfield.store(Int(0)) somewhere before that section of code is called, it should fix the issue.
Though I recognize this constraint can be a bit annoying, since it’s sometimes useful to rely on the default value of 0 for scratch slots. Let us know if you think this safety check should be somehow made optional or turned into a warning instead.