Redo "Disallow using `@goto` to skip finally blocks" (#63009)
I agree we should treat goto out of catch/else consistently with goto out of
try, but have some objections to the implementation in 60979.
- Introducing a new `oldX` Expr head is not (sanely) repeatable if we want to
disallow some other misuse of `X`
- It requires a desugared macro definition with the internal signature (and a
special case for `@goto` in the parser) to produce different-version syntax:
```julia
macro goto(name::Symbol)
return esc(Expr(:oldsymbolicgoto, name))
end
function var"@goto"(__source__::Core.MacroSource, __module__::Module, name::Symbol)
return esc(Expr(:symbolicgoto, name))
end
```
- We want lowering to know the difference between new and old, but user macros
never want to see a form like `oldsymbolicgoto`
- It broke the existing check that we don't jump from a try block
- It left the change TODO in JuliaLowering
We already have the ability to have syntax carry its version and have macros
produce versioned syntax in JuliaLowering, so I could easily version it there
(several other syntax bugs are cleaned up in the same way already). However:
- It's possible that the first SyntaxTree-by-default syntax version is 1.15 (or
else typegroup/labelled break stuff would be bundled with new macros), which
would push this change one syntax version further than it was meant to be
- I think there is agreement that this is a bugfix
- pkgeval was clean when it was fixed for all syntax versions
- It's extra maintenance burden to commit to different behaviour between
versions
so for this particular change, I think it would be best to make it in all syntax
versions, and that's what this PR does. Other opinions are welcome.
I'm doing this now as it's a prerequisite to unifying what "syntax version" means
between the parser and lowering, which is a prerequisite to hooking
JuliaLowering up properly.
This PR also implements the old and new try/catch goto checks in JuliaLowering,
and fixes the old check under flisp lowering.