[Chapel Merge] Fix an error handling bug with reductions inside foralls that could throw

Branch: refs/heads/main
Revision: ec5b799560ecfd5d29f84881fe9131866754d72d
Author: lydia-duncan
Link: Fix an error handling bug with reductions inside foralls that could throw by lydia-duncan · Pull Request #24692 · chapel-lang/chapel · GitHub
Log Message:
Fix an error handling bug with reductions inside foralls that could throw (#24692)

[reviewed by @DanilaFe]

I was encountering a bug where a reduction inside a forall loop that
also called a throwing function would trigger an internal compiler
error.

The internal compiler error was an assertion error during error
handling. It appeared to be happening because the reduction was
transformed into a forall, but the forall wasn't turned into a loop
that could throw, so wasn't getting tracked on the tryStack, but
we were still marking it as entered. So when we then tried to
"exit" that forall, we'd run into trouble because the forall in the
tryStack wasn't the forall we were trying to exit.

This bug was impacting HPO.

Add a test locking in that we don't encounter the internal compiler
error any more.

Passed a full paratest with futures.

Compare: Comparing a37c49637bbf2e6ba7fc5b296abbfa088e45e498...89a4d4a8165c0dddda2cb2c95ddc2635a9d56f7a · chapel-lang/chapel · GitHub

Diff:
M compiler/passes/errorHandling.cpp
A test/errhandling/lydia/reductionInForall.chpl
A test/errhandling/lydia/reductionInForall.good
https://github.com/chapel-lang/chapel/pull/24692.diff