effekt icon indicating copy to clipboard operation
effekt copied to clipboard

Cannot escape double quotes in extern strings

Open jiribenes opened this issue 6 months ago • 2 comments

Minimal example:

extern pure def foo(): String = "\"this is a string\""

throws an error as \" is not allowed in extern strings: Screenshot 2023-12-19 at 12 13 22

However, double quote escaping works in normal strings:

val foo = "\"this is my quoted string\"

I believe that my actual use case needs the double quotes in an extern string because it's a separate parameter that I have to provide:

extern type ByteArray
extern pure def fromString(s: String): ByteArray = "(new TextEncoder().encode(s))"
extern pure def toString(b: ByteArray): String = "(new TextDecoder(\"utf-8\").decode(b))"

Related: #350, #202

jiribenes avatar Dec 19 '23 11:12 jiribenes