A compiler flag to enforce precise lifetimes everywhere?

Hello folks,

Can we consider a compiler flag to enforce precise lifetimes by default everywhere? (including local variables)

Maybe there gonna make some performance impact, but imprecise-by-default for local variables needs too much attention to write correct programs. And I believe default behavior should be tuned for safety (which also implies correctness) first. Just like -ffast-math option. You get safet and correct by default and take the benefit only if you fully understand and can afford the trade off.

I discovered this while I was digging into a bug. Thanks to nice folks here, I could resolve the issue. But I still think this is too much surprise as this is quite hard to figure out and makes writing correct programs in Swift far more difficult. And AFAIK, ease of use is also one of important goal of Swift.

1 Like