-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Lift Template Literal Restriction on Backslashes #12700
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
This was bumped to stage 4 in 2017-03. It is slated for inclusion in ES2018 https://github.com/tc39/proposals/blob/master/finished-proposals.md |
Interested in this😉 |
@Kingwl In implementing it, or using it? 😃 |
related #5291 |
I don't know why that'd be necessary, I think you just need to potentially thread through some extra context when you're scanning these things (which is what the ECMAScript spec does in the grammar now). But I might've missed something, so feel free to send the PR and we can iterate on it! |
By the way, template emit now uses a helper, so the proposed emit is a little different. |
Should the new grammar be always used or what options are needed? |
seems could fixed in this change |
how could i know that template is tagged in,scanner? i have no idea😓 |
I think you'll have to actually add a rescan method on the scanner (e.g. |
ahhh, |
Overview
Everyone loves LATEX so ESNext will likely allow tagged template strings to contain backslashes on any sequence - even ones that look like they might contain an invalid Unicode escapes.
In other words, something like
is now valid, whereas previously it would be considered an error.
Reference: https://tc39.github.io/proposal-template-literal-revision/
As of this writing, the linked proposal is at Stage 3.
Notes
This restriction lift doesn't apply to untagged template strings. For example:
Because there is no appropriate representation for a "cooked" string that contains one of these escapes, the returned value at a position on the top-level array will be
undefined
, but the raw representation will be available. For example:// Prints 'true' twice.
tag
\unicode and \u{55}
Proposed Emit
Input:
Output:
The text was updated successfully, but these errors were encountered: