Why is this closure slower the second time it is used?

Yes, but not if the code is at top level, or if you just move let a = Double(1) out of test() to top-level.

I just posted about this in the other thread.