Fix ArkRegex quantifier issue - #1535
Conversation
|
To reduce ternary nesting here (and slightly improve scalability): r["min"] extends never ? null
: r["max"] extends never ? null
: rI was considering adding a someExtends<[r["min"], r["max"]], never> extends true
? null
: rBut I'm unsure whether this is worth it. |
ssalbdivad
left a comment
There was a problem hiding this comment.
Hey thanks for submitting this! Would love to see these scenarios handled better and appreciate the detail mirroring the behavior of new RegExp 1:1 here, but we actually have the luxury of failing for cases like this that are almost certainly a mistake.
Can we adjust the handling here so that for invalid quantifiers, we write a descriptive error like Quantifier ${actual} must be a natural number?
We should be able to use the existing parseInteger type to determine this or tryParseInteger which has a builtin parameter for an error message. We could potentially prompt the user to use an escape char for the opening { if they really do want the literal string, although I think that will be quite rare and I don't want the message to be too verbose so up to you.
|
That makes sense to me, I'm not a huge fan of the implicit literal treatment for invalid quantifiers for native It's worth noting that in the test cases I'll try to get to it in the weekends. If I'll have any questions or notes I'll let you know. Thanks for the review! |
|
I fixed it, some things I was uncertain about:
Edit: Looks like a step failed, that's not my strong suit so I'll give this a look on another day. |
|
Wow this is perfect I love it- great work 💯 The CI failure is just due to some recent issue in node 25 so I'm going to merge this as is and will publish in the next few days. Thanks again! |
|
Thanks a lot, David! Learned a lot working on this, so it's great to be able to contribute back 🙌 |
Fixed ArkRegex quantifier issues (#1531, #1534)