-
Notifications
You must be signed in to change notification settings - Fork 450
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
Consider syntax erroring if the same character is repeated in the character class #287
Comments
I'm not totally sure we want to do this. It seems like a good idea at first, but what if you used two character classes that partially overlapped? e.g., Also, this would be a breaking change. While 1.0 is looming, I'm not sure it's worth it. |
I was thinking about a simple rule for literal characters only and maybe for exactly duplicated character classes as well. I can't imagine a realistic situation when it is intentional to have such obvious repetitions. But I think they can arise by accident. I don't know what is the best solution here: I'd made it a syntax error, but I don't have much expertise :) Another option would be to add a lint for this, but it won't be as effective (and won't work for user provided regular expressions).
Imo, it's better to fix rough edges before 1.0 rather than leave them as it is. But again, can't say for sure if it is a rough enough edge. |
I thought about this. Here's why I think we shouldn't do it:
While I do kind of agree with your arguments, I just feel like there isn't enough to break rank with everyone else. |
Hi! Today, I've spend some time debugging regex like
[a:digit:]
which I wrongly assumed should work like[a[:digit:]]
. For me, it would be nice ifregex
failed to compile this regex because:
is repeated twice :)The text was updated successfully, but these errors were encountered: