A string containing only a Unicode escape sequence causes an error #808
Labels
bug
Something isn't working
good first issue
Good for newcomers
Hacktoberfest
Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com
lexer
Issues surrounding the lexer
Milestone
Describe the bug
If a string is composed only of a Unicode escape sequence (e.g.
"\uABCD"
), then an error occurs instead of producing a string.To Reproduce
"\u00A7"
(that's the code for the section sign. It's not important, as the bug applies to any escape sequence)
Expected behavior
The string is valid, and is not supposed to throw an error. The syntax for string literals can be found here.
Build environment (please complete the following information):
Windows 10
Version 1909 (OS Build 18363.1082)
x86_64-pc-windows-msvc
rustc 1.46.0 (04488afe3 2020-08-24)
Additional context
Spec: https://tc39.es/ecma262/#sec-literals-string-literals
MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar
As far as I can tell, the bug is caused by an issue in syntax/lexer/string.rs where once a Unicode escape sequence is detected, it skips checking for
"
and believes the string has finished without a"
.The text was updated successfully, but these errors were encountered: