-
Notifications
You must be signed in to change notification settings - Fork 66
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
Warn if an always-match clause is not the last alternative #576
Comments
It is definitely possible. The idea that for each node you should calculate statistic -- how much characters node will consume when matched? It is better to calculate the minimum and maximum. Here we only need the minimum, and the maximum may be needed in other analyzes. If alternative have a branch with Actually, I already wrote such pass (but not used it in any project) |
This probably also applies to lookaheads. |
Maybe. Also, I realized, that the proposed solution will catch only part of situations. start1
= [a-z]
/ [bcd] // never matched because the previous alternative matches all what this matches
start2
= 'prefix'
/ 'prefix-literal' // never matched because the previous alternative matches all what this matches
|
Consider:
This is unlikely to produce the output that the author intended, since the "foo" will never be checked. I wonder if we can detect this pattern and at least warn on it?
The text was updated successfully, but these errors were encountered: