It's late, and I'm sure this is stupid error, but why is this not working?

Is it because the random is pure? It will return a different value for the second branch and the set won’t it?