Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Differences between escapes in ReScript strings and JavaScript strings #469

@kevinbarabash

Description

@kevinbarabash

The following escapes differ from standard JS strings:

  • \o escape does nothing in JavaScript strings, "\o123" is interpreted as "o123" in JS
  • decimal escapes in ReScript, e.g. \123, in non-strict mode JS these are treated as octal escapes and in strict-mode JS they are forbidden

For the first one, we should remove any checking we were doing around whether the \o was a valid octal escape. JS treats unknown escapes by stripping the leading \ from the escaped char. I proposed we do the same.

For the second one, we could support JS-style octal escapes in ReScript strings, but I think that might lead to confusion if someone is switching between Ml syntax and Res syntax. If we follow the strict-mode behaviour and only allow \0 then this shouldn't be an issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions