Ran into some #Haskell #heisenbug with stable names.

So I makeStableName on a bunch of evaluated objects. Later when I look them up, I didn't re-eval (since they are already evaluated supposedly).

But, I suspect under some conditions the lookup function might get some thunk (to the already eval'd object), somehow. Resulting in a miss.

To debug, in the miss path, I added an eval and a lookup on that. But that made the miss go away in the first place.

So kids, always eval your stable stuff.

Funny enough just adding the second makeStableName (on the miss path), even without eval, made the miss path not trigger as well. I guess some compiler optimization or rearrangement magic.
Was too happy too early. I'm left with the impression that either the StableName reference changes despite eval (should not), or something weird wrapping happens, or whatever. Better not rely on that equality.