mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:57:44 +00:00
LibJS: Treat private identifier as divisible token
And also make sure private identifiers are correctly checked when synthesizing a binding pattern.
This commit is contained in:
parent
afde1821b5
commit
e751dcea43
4 changed files with 16 additions and 0 deletions
|
@ -83,6 +83,19 @@ test("static fields", () => {
|
|||
expect("A.#simple").not.toEval();
|
||||
});
|
||||
|
||||
test("slash after private identifier is treated as division", () => {
|
||||
class A {
|
||||
static #field = 4;
|
||||
static #divided = this.#field / 2;
|
||||
|
||||
static getDivided() {
|
||||
return this.#divided;
|
||||
}
|
||||
}
|
||||
|
||||
expect(A.getDivided()).toBe(2);
|
||||
});
|
||||
|
||||
test("cannot have static and non static field with the same description", () => {
|
||||
expect("class A { static #simple; #simple; }").not.toEval();
|
||||
});
|
||||
|
|
|
@ -17,6 +17,7 @@ test("slash token resolution in lexer", () => {
|
|||
expect("+a-- / 1").toEval();
|
||||
expect("a.in / b").toEval();
|
||||
expect("a.instanceof / b").toEval();
|
||||
expect("class A { #name; d = a.#name / b; }").toEval();
|
||||
|
||||
// FIXME: Even more 'reserved' words are valid however the cases below do still need to pass.
|
||||
//expect("a.void / b").toEval();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue