Skip to content

escape all non-printable or non-ASCII characters in strings #1265

@michaelficarra

Description

@michaelficarra

I ran into this error.

$ cat test.purs
module Main where
string = "\x1B"
$ psc test.purs
Compiling Main
Writing output/Main/index.js
Writing output/Main/externs.purs
$ psc-bundle 'output/**/*.js'
The module could not be parsed.
$ cat output/Main/index.js
// Generated by psc version 0.7.1.0
"use strict";
var string = ";
module.exports = {
    string: string
};

The error from psc-bundle occurs because a literal \x1B character is printed in the string. This is legal JavaScript, but the library we're using to parse it doesn't seem to handle it properly. I'm sure there is also poor support for unicode in this and other JavaScript tooling. We should use escape sequences for all but the simplest set of characters: printable ASCII.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions