Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make regex literals capture $/ and $!
These are then used when the regex is evaluated in boolean context, rather than using dynamic scope, which is not reliable given that `$_` is no longer dynamic as of 6.d. Previously, we would not lower away `$_` if we saw a regex literally present in that scope, however this cannot handle the at-a-distance uses. Defining these semantics will, on the upside: 1. Provide the correct behavior for immediate literal uses of /.../, which is by far the common case. 2. Provide a good means for `.grep: { /foo/ }` to work (it has always been a bit of a "works by accident" before now). 3. Avoid weird issues of finding a `$_` at a distance just because the closest one was undefined. In fact, things like `so /foo/` only ever worked before now because `so` did not put a defined value into its `$_`! Worse still, if you wrote `given $foo { if /.../ { say 1 } }` and `$foo` was undefined, you'd not get a warning, but instead it would magically match against the first `$_` in dynamic scope that has a defiend value! 4. Do nothing but good for performance. On the downside, it means we have to consider one spectest 6.d errata. This patch also does not currently retain the previous semantics for 6.c, however I can see how to do that and look into it if there's some consensus for us to go in this direction.
- Loading branch information
Showing
3 changed files
with
30 additions
and
29 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
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
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