I noticed that \" wasn’t working and when I started digging into string escapes, I noticed that ReScript supports octal escapes using \o and decimal escapes. JavaScript strings do not support \o octal escapes and \123 is treated as an octal escape in non-strict mode and is not allowed in strict mode, neither of which is a decimal escape.
That brings me to my question: should string escapes in ReScript match those in JavaScript?
What would this mean?
- numeric escapes like
"\123"would not be allowed in .res(i) files, with the exception of"\0" - numeric escapes in .ml(i) files would be converted to hexadecimal escapes when converting .ml(i) files to .res(i) (this is what’s output in .js files)
- the
"\"in"\o123"would be ignored and would be equivalent to"o123"
Here’s a link to a PR that implements these changes along with a fix for the \" issue: https://github.com/rescript-lang/syntax/pull/470.