Skip to content

Commit 5180a97

Browse files
v-gbBurntSushi
authored andcommitted
compile: support empty patterns better
Some were rejected explicitly with this "alternations cannot currently contain empty sub-expressions" error. Some were causing alternations to be compiled into automaton matching a different regex. The root of the issue is that the compilation of the Empty pattern returns Patch { entry: self.insts.len(), .. }, that is it claims its entry point is the next instruction. This only works if the next instruction is unconditionally executed, which is not true for alternations. So we return None instead, and let the callers decide how to handle an empty regex. Fixes #524, Fixes #659, Closes #677
1 parent ed581f5 commit 5180a97

File tree

2 files changed

+170
-84
lines changed

2 files changed

+170
-84
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ Bug fixes:
55

66
* [BUG #523](https://github.com/rust-lang/regex/pull/523):
77
Add note to documentation that spaces can be escaped in `x` mode.
8+
* [BUG #524](https://github.com/rust-lang/regex/issue/524):
9+
Add support for empty sub-expressions, including empty alternations.
10+
* [BUG #659](https://github.com/rust-lang/regex/issue/659):
11+
Fix match bug caused by an empty sub-expression miscompilation.
812

913

1014
1.3.7 (2020-04-17)

0 commit comments

Comments
 (0)