Commit cb7412f
committed
syntax: fix empty char class bug in HIR printer
When a character class is empty, the HIR printer would emit '[]', which
is not a valid regex. (Since if a ']' immediately follows an opening
'[', then the ']' is interpreted literally and not a closing bracket.)
Instead, we write '[a&&b]'. We could also do things like '(?u:\P{any})'
or '(?-u:[\x00-\xFF])', but '[a&&b]' doesn't require any flags and also
seems really obvious: the intersection of two distinct characters is
obviously empty.1 parent cd1c46d commit cb7412f
1 file changed
+11
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
128 | 131 | | |
129 | 132 | | |
130 | 133 | | |
| |||
143 | 146 | | |
144 | 147 | | |
145 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
146 | 152 | | |
147 | 153 | | |
148 | 154 | | |
| |||
359 | 365 | | |
360 | 366 | | |
361 | 367 | | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
362 | 373 | | |
363 | 374 | | |
364 | 375 | | |
| |||
0 commit comments