Skip to content
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

Avoid "Inlined without wrapping" #14

Open
bergus opened this issue Aug 12, 2015 · 2 comments
Open

Avoid "Inlined without wrapping" #14

bergus opened this issue Aug 12, 2015 · 2 comments
Assignees

Comments

@bergus
Copy link
Collaborator

bergus commented Aug 12, 2015

The Expressions table does allow arbitrary values to be inlined "without inlining" in some contexts. I think that's a bad idea. This wording seems to suggest that the following things are allowed:

RegExp.make `a{${"1,2"}}` // /a{1,2}/
RegExp.make `a{1,${/2/}}` // /a{1,2}/
RegExp.make `a{${/b/}}` // /a{b}/ - matches "a{b}" literally
RegExp.make `a{${"1}b{2"}}` // /a{1}b{2}/
RegExp.make `a{${""}}` // /a{}/ - matches "a{}" literally

Urgh. Can we please do ToNumber on the interpolation value in the context of DecimalDigits, and throw a TypeError if it yields NaN?
So that the only allowed patterns are basically

RegExp.make `…{${repeat}}`
RegExp.make `…{${min},}`
RegExp.make `…{${min},${max}}`

where each of those variables has to be a number (or at least numeric).

@mikesamuel
Copy link
Owner

Should

RegExp.make`x{3,${ Infinity }}`

produce /x{3,}/

What about

RegExp.make`a{${ [1,2] }}`

@bergus
Copy link
Collaborator Author

bergus commented Aug 12, 2015

@mikesamuel

Should RegExp.makex{3,${ Infinity }}`` produce /x{3,}/?

Sure, seems reasonable. That's what the Quantifier evaluates back to anyway…

What about RegExp.makea{${ [1,2] }}``?

No, that's not a number (and can't be coerced to one, like ["1"] could :-/). I don't see a reason to accept arrays. What if they're empty? What if they're longer than 2? If you are (ab)using arrrays as tuples and know that it has two elements, then it's not much harder to write

RegExp.make `a{${t[0]},${t[1]}}`

(Convince me that you need arrays here!)

@mikesamuel mikesamuel self-assigned this Oct 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants