Add resolving for capture groups.
We would previously not perform proper resolving of capture groups.
Instead we emitted a magic C++ identifier so this only resolved at C++
compile time. This introduced a number of downsides:
- incorrect uses of capture groups via `$1`, `$2`, ... outside of field
hooks which defined the magic captures was impossible to diagnose;
instead this caused failed C++ compilation
- code rewrites needed to treat captures special since their use was not
correctly reflected on the AST
This patch lowers uses of capture keywords to the identifier name
much earlier so it behaves like any other use of an identifier.
Closes #2222.
Drop stray CFG edge for `while` loops with inits.
It looks like this was simply added by accident, and never caught since
we had no test. This patch fixes the code and adds a test.