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

StringGetOwnProperty does not produce the same strings that the lexer produces #1459

Closed
raskad opened this issue Aug 10, 2021 · 0 comments · Fixed by #1460
Closed

StringGetOwnProperty does not produce the same strings that the lexer produces #1459

raskad opened this issue Aug 10, 2021 · 0 comments · Fixed by #1460
Labels
bug Something isn't working
Milestone

Comments

@raskad
Copy link
Member

raskad commented Aug 10, 2021

Describe the bug
The StringGetOwnProperty operation used when indexing a string ("abc"[1]) does not produce the same string that the lexer produces. This matters for UTF16 surrogates.

Currently the lexer uses String::from_utf16_lossy (see UTF16CodeUnitsBuffer::to_string_lossy) and StringGetOwnProperty uses char::from_u32(u32::from(utf16_val)).map_or_else(|| Value::from(format!("\\u{:x}", utf16_val)), Value::from) (ignore the conversion to Value).

To Reproduce
This JavaScript code reproduces the issue:

if ('𝌆'[1] == '\udf06') {
    console.log(true)
} else {
    console.log(false)
}

Expected behavior
Both should produce the same strings, because the spec expects them to be equal.

Build environment:

  • OS: Linux
  • Version: fff3974
  • Target triple: x86_64-unknown-linux-gnu
  • Rustc version: rustc 1.53.0 (53cb7b09b 2021-06-17)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants