forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibJS: Allow Unicode escape sequences in identifiers
For example, "property.br\u{64}wn" should resolve to "property.brown". To support this behavior, this commit changes the Token class to hold both the evaluated identifier name and a view into the original source for the unevaluated name. There are some contexts in which identifiers are not allowed to contain Unicode escape sequences; for example, export statements of the form "export {} from foo.js" forbid escapes in the identifier "from". The test file is added to .prettierignore because prettier will replace all escaped Unicode sequences with their unescaped value.
- Loading branch information
1 parent
c5b5c77
commit 1259dc3
Showing
7 changed files
with
162 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Base/home/anon/Source/js | ||
Userland/Libraries/LibJS/Tests/eval-aliasing.js | ||
|
||
Userland/Libraries/LibJS/Tests/unicode-identifier-escape.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
Userland/Libraries/LibJS/Tests/unicode-identifier-escape.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
test("basic escapes", () => { | ||
var foo = {}; | ||
foo.brown = 12389; | ||
|
||
expect(foo.brown).toBe(12389); | ||
expect(foo.br\u006fwn).toBe(12389); | ||
expect(foo.br\u{6f}wn).toBe(12389); | ||
expect(foo.\u{62}\u{72}\u{6f}\u{77}\u{6e}).toBe(12389); | ||
}); | ||
|
||
test("non-ascii escapes", () => { | ||
var foo = {}; | ||
foo.ππ»πΈππ· = 12389; | ||
|
||
expect(foo.ππ»πΈππ·).toBe(12389); | ||
expect(foo.ππ»\ud835\udcf8ππ·).toBe(12389); | ||
expect(foo.ππ»\u{1d4f8}ππ·).toBe(12389); | ||
expect(foo.\u{1d4d1}\u{1d4fb}\u{1d4f8}\u{1d500}\u{1d4f7}).toBe(12389); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.