<div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div style="margin-left:40px"><span style="font-family:monospace">final int x;</span></div><div style="margin-left:40px"><span style="font-family:monospace">int neg_x = 0;<br></span></div><div style="margin-left:40px"><span style="font-family:monospace">try {</span></div><div style="margin-left:40px"><span style="font-family:monospace">    x = method();</span></div><div style="margin-left:40px"><span style="font-family:monospace">    neg_x = -x;       // "trailing trivial stuff"<br></span></div><div style="margin-left:40px"><span style="font-family:monospace">} catch (Exception e) {</span></div><div style="margin-left:40px"><span style="font-family:monospace">    x = 0;<br></span></div><div style="margin-left:40px"><span style="font-family:monospace">}</span><br></div><div><br></div><div><div>At this point, is it even worth it to do this more complicated analysis? It's not much gain for all that work when compared to the original simpler fix.</div></div></div></div></blockquote><div><br></div><div>If it is worth it or not of course is a question of preference. To my mind, it is much cleaner than the special rule for "last statement is assignment". I think the only way to decide if it is worth it or not is if many more people would voice their opinion. To me it just feels too special to talk about the "last assignment" and what is that last statement.</div><div><br></div><div>To me actually the most strange property of the "last assignment" rule is that an "if-else" chain would not work. Not so much that I want to make one more trivial assignment. But I think if the rule wants to allow the "if-else" chain then it is probably easier to allow your last example as well.</div><div><br></div><div>As for the exceptions: There can be other middle grounds here to simplify stuff. I originally thought that a statement or expression can either throw an exception or not, and if it can, we assume that it may throw literally anything (so, `x = a.b;` is assumed to potentially throw an `IOException`). That would make the rules a lot simpler, yet would be still less surprising in my opinion.</div></div></div>