You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The variable is not "shadowed". It is reassigned. Escape analysis works on variables. One value assigned to the variable str does indeed escape. The result is therefore correct.
You might argue a broader point, that we should use a much more sophisticated escape analysis that works on values instead of variables, but I am skeptical that there's much evidence for that.
In any event when you really care about escape analysis results there is a clear workaround, as you've shown.
If you did use a shadowed variable that would work too:
Using
go1.5
Compile the following package:
I currently see (unrelated lines removed):
I expect to see (unrelated lines removed):
The text was updated successfully, but these errors were encountered: