-
-
Notifications
You must be signed in to change notification settings - Fork 793
fix(estree/ast): fix lossy StringLiteral.value
#9965
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
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Instrumentation Performance ReportMerging #9965 will not alter performanceComparing Summary
|
| let raw = self.0.raw.unwrap(); | ||
| JsonSafeString(&raw[1..raw.len() - 1]).serialize(serializer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this would work similar to codegen, but this doesn't seem to work.
For example, when js has single quoted with double quote inside:
'\uD800"'this ends up as invalid json:
{
"type": "Literal",
"start": 0,
"end": 9,
"value": "\uD800"", <-- double quote inside double quote
"raw": "'\\uD800\"'"
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could check what quotes were used in original code via the 1st byte of raw field. If ", then the way you've done it should work. If ', then you'd need to replace " with \".
I actually have a half-done PR doing exactly that. But was having trouble getting conformance to pass. Maybe after #9964 it will. I'll try and finish it off.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds good. I think there is a weird case like this unnecessary escape '\"', so perhaps it requires traversing manually character by character? Anyways, I'll close this in favor of your fix 🙏
I was also not sure about raw deser, so I was mostly giving up. 😅
c80b7db to
d38e665
Compare
aaf6bf2 to
eaea5fd
Compare
d38e665 to
92c54aa
Compare

I attempted fixing this but realizing #9965 (comment) and it might be out of my reach 😓 Please feel free to take over.
In terms of test262 conformance, there was no edge case like #9965 (comment). So, remaining surrogate related mismatch is a following form. This difference is actually not visible in js world since the difference of acorn output is due to how
JSON.stringifyautomatically normalizes string.