[optimizer] don't merge A+B|B => A?+B
for ChoiceRule
#11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
we actually can't do this.
for
A+B1|B2
:A
matches, tries to matchB1
.B1
matches,A+B1
matches, andA+B1|B2
matches.B1
fails,A+B1
fails, fallback toB2
B2
matches,A+B1|B2
matchesB2
fails,A+B1|B2
fails.A
fails, try to match B2.B2
matches,A+B1|B2
matchesB2
fails,A+B1|B2
fails.however, for
A?+B
:A
matches, tries to matchB
B
matches,A?+B
matchesB
fails, fail. (no fallback path to matchB
only)A
fails, tries to matchB
B
matches,A?+B
matchesB
fails, fail.the problem is for
A?+B
, whenA
matches, it wants to match aB
, and success only when a validB
matches.if
A
matches butB
doesn't,A?+B
fails.this actually behaves different than
A+B|B
.