AstGen: properly restore previous state after temporary changes

Before this, if a compile error occurred, it would cause the previous
value for e.g. the function scope to not get reset. If the AstGen
process continued, it would result in a violation of the data
guarantees that it relies on.

This commit takes advantage of defer to ensure the previous value is
always reset, even in the case of an error.

Closes #8920
3f5ca3920aAndrew Kelley committed on 5/29/2021, 12:29:56 AMparent54f774f
2 files changedLine totals unavailable