Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong character encoding when using tagged templates #6750

Open
HrX03 opened this issue May 5, 2024 · 3 comments
Open

Wrong character encoding when using tagged templates #6750

HrX03 opened this issue May 5, 2024 · 3 comments
Assignees

Comments

@HrX03
Copy link

HrX03 commented May 5, 2024

Tagged templates seem to format special characters erroneously, for example gets compiled into \xe2\x80\x9c which gets parsed/printed/shown as �

Example playground file:
https://rescript-lang.org/try?version=v11.1.0&code=DYUwLgBCAeELwQBQGcwCcCWA7A5sgNBAPoCUAXBKprvAHwQDeAUBBAFLIB0AgmmgIYBPTgCsA9tgDqGMAAtEAIgWEq2PCSYBfJkwDCYrMjGhOwMTkQMYAA0A4BNc0kgA

Rescript version: v11.1.0

@cometkim
Copy link
Contributor

cometkim commented May 8, 2024

there are three noticeable bugs in the result

  1. Shouldn't the curly brace ({ ... }) be syntax error?
  2. ex`...` impl shouldn't be inlined
  3. and as you reported, wrong encoding

@zth
Copy link
Collaborator

zth commented May 9, 2024

  1. Shouldn't the curly brace ({ ... }) be syntax error?

No, that's just another block that returns at the end. It's fine.

  1. ex`...` impl shouldn't be inlined
  2. and as you reported, wrong encoding

You can get this to work for external tagged template functions: https://rescript-lang.org/try?version=v11.1.0&code=AIFwhg5hCmAmAq0C2AHANmE0AE0AeWATgHZhq54Bc2AFGIYWAJ4A8AziIQJbEQB8AGmz1GrAPp8AlNgC8fbB269Z2AET5VAKE0BhAPbE2etNAB0aPRBoBvfAANAOAR2AvpM1A

However, right now there's a difference between external (bindings) and internal (written in ReScript) tagged template functions, where externals emit the tagged template syntax, but the internal ones are treated like regular functions. cc @tsnobip

@tsnobip
Copy link
Contributor

tsnobip commented May 9, 2024

hmm shoot, this is quite surprising given all strings in rescript should now be in unicode. Given the original PR was quite old, maybe it reused some out-of-date logic around strings.

@tsnobip tsnobip self-assigned this May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants