-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[ .. a]
pattern breaks matches
#6909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Confirmed. Bugs where we actually generate the wrong code are pretty bad, so fixing this is probably decently high priority. Not sure it actually fits for a milestone, though? |
OK, I've figured out what is going on. The problem is that the matcher is too strict when deciding what patterns are included in some condition. Essentially the problem is that it decides that the condition that are relevant are "length > 1" and "length > 0" and decides that [2, .. _] is the only pattern that matches "length > 1", which is obviously bogus. Fixing this seems a bit tricky, since we need to be able to properly expand out the patterns while still properly handling bindings. Note that this seems like a degenerate case, since the last pattern could just be replaced with a _, but there are more complicated and interesting things where this happens too. |
Oh, no, there is a pretty simple solution to this. The trick is, when checking submatches generated by a vector length check, set it up so that if none of the subpatterns match, it goes to the next vector length check. I'm explaining it poorly, but it is a really simple fix. |
Simple fix has problems, though. So have a more complex fix. Which also has problems. Still investigating. |
OK, have it all fixed. Just trying to document it well at this point. |
This should print
ok
, but printsnot ok
.The problem seems to be the
[.. _]
pattern, since if this is replaced by_
ora
, it printsok
. It also printsok
when matching on an empty vector. (The use of_
is not important.)The text was updated successfully, but these errors were encountered: