mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 10:07:15 +02:00
LibJS: Initial class implementation; allow super expressions in object
literal methods; add EnvrionmentRecord fields and methods to LexicalEnvironment Adding EnvrionmentRecord's fields and methods lets us throw an exception when |this| is not initialized, which occurs when the super constructor in a derived class has not yet been called, or when |this| has already been initialized (the super constructor was already called).
This commit is contained in:
committed by
Andreas Kling
parent
a535d58cac
commit
7533fd8b02
Notes:
sideshowbarker
2024-07-19 05:19:30 +09:00
Author: https://github.com/jack-karamanian Commit: https://github.com/SerenityOS/serenity/commit/7533fd8b025 Pull-request: https://github.com/SerenityOS/serenity/pull/2533 Reviewed-by: https://github.com/linusg
@@ -70,6 +70,22 @@ try {
|
||||
assert(a[2] === 3);
|
||||
assert(o4.test === undefined);
|
||||
|
||||
var base = {
|
||||
getNumber() {
|
||||
return 10;
|
||||
}
|
||||
};
|
||||
|
||||
var derived = {
|
||||
getNumber() {
|
||||
return 20 + super.getNumber();
|
||||
}
|
||||
};
|
||||
|
||||
Object.setPrototypeOf(derived, base)
|
||||
assert(derived.getNumber() === 30);
|
||||
|
||||
assertIsSyntaxError("({ foo: function() { super.bar; } })")
|
||||
assertIsSyntaxError("({ get ...foo })");
|
||||
assertIsSyntaxError("({ get... foo })");
|
||||
assertIsSyntaxError("({ get foo })");
|
||||
|
||||
Reference in New Issue
Block a user