Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/IRGen/ESTreeIRGen-expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,7 @@ Value *ESTreeIRGen::genObjectExpr(ESTree::ObjectExpressionNode *Expr) {
Builder.createIdentifier("get " + keyStr.str()),
/* superClassNode */ nullptr,
Function::DefinitionKind::ES5Function,
/* homeObject */ nullptr,
/* homeObject */ capturedObj,
/* parentNode */ propValue->getterProp);
}

Expand All @@ -1645,7 +1645,7 @@ Value *ESTreeIRGen::genObjectExpr(ESTree::ObjectExpressionNode *Expr) {
Builder.createIdentifier("set " + keyStr.str()),
/* superClassNode */ nullptr,
Function::DefinitionKind::ES5Function,
/* homeObject */ nullptr,
/* homeObject */ capturedObj,
/* parentNode */ propValue->setterProp);
}

Expand Down
16 changes: 16 additions & 0 deletions test/hermes/object-literal-getter-super.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,19 @@ var object = {
Object.setPrototypeOf(object, proto);
print(object.a);
// CHECK: a proto m

// Test that accessors without computed names can also refer to super.
(function () {
let v1 = {
get a() {
let x = super.m;
print(x);
}
}
let parent = { m: 12 };
v1.a;
// CHECK-NEXT: undefined
Object.setPrototypeOf(v1, parent);
v1.a;
// CHECK-NEXT: 12
})();