-
Notifications
You must be signed in to change notification settings - Fork 38
Align ReScript string escapes with JS strict-mode #470
Conversation
@@ -20,48 +20,48 @@ include { | |||
) => | |||
t('value) = | |||
"" | |||
"BS:6.0.1\132\149\166\190\000\000\000#\000\000\000\r\000\000\000&\000\000\000#\145\160\160A\160$size@\160\160A\160$root@\160\160A\160'compare@@"; | |||
"BS:6.0.1\x84\x95\xa6\xbe\0\0\0#\0\0\0\r\0\0\0&\0\0\0#\x91\xa0\xa0A\xa0$size@\xa0\xa0A\xa0$root@\xa0\xa0A\xa0'compare@@"; |
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 converted tests strings using the playground and copy/pasting the string from the JS output.
I just ran |
We could change the parse tree to store the js escapes. This will mean we'd have to update the ml printer to convert those escapes back to ml, but given the focus of this project moving forward appears to the res syntax, I think that makes sense. |
|
@kevinbarabash this is probably a good time to revisit this task, if still interested. |
@cristianoc thanks for the ping. I don't have time to push this forward right now. Given that things have changed it's probably best for someone to look at this with fresh eyes. |
This fixes the issue raised in #469. I added more test cases to verify that the behaviour is also consistent across string literal constants and string literals that appear in other places such as patterns and object keys. This means the following:
\o
are ignored since since that's how they're handled in JavaScript strings\123
are not allow in .res(i) files except for\0
Test Plan:
make
make roundtrip-test
TODO:
master
)[ ] special caseIt's not possible to do this consistently since\000
to\0
instead of\x00
?\0004
can't be converted to\04
since\04
is not allowed in strings in JavaScript's strict mode. It's easier to use\x00
even if\0
is more succinct.