Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previously, we would only ever flatten away lexical scopes if we saw that there were no declarations inside of that scope, the only special case being `$_`, which was handled specially. There was also some special mechanism in place to try and handle topic rebinds correctly. Recently, lexical to local lowering became more powerful, able to deal with normal lexical variables rather than just parameters and name bindings. This handling takes in $_ too. This commit replaces the scope flattening mechanism with one that, at its heart, will flatten in an immediate block if all of its variables were lowered. This means that in a program like: my $a = 42; if $a > 21 { my $b = 10; if $b < 200 { say $a + $b } } Then both of those scopes flatten away, thanks to both `$a` and `$b` having been lowered. Previously, only the innermost one would have been, thanks to the declaration of `$b`. Since the `$_` in each block is now also lowered to a local when possible, then we can replace the `getouterlex` calls with a simple bind, and do away with the topic preservation mechanism, which was always rather cheaty.
- Loading branch information
Showing
1 changed file
with
69 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
“Stsah”