Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
[Merge chakra-core/ChakraCore@083ab297e1] [1.6>1.7] [MERGE #3398 @suwc]…
Browse files Browse the repository at this point in the history
… OS12503560: assignment to super[prop] not accessing base class property

Merge pull request #3398 from suwc:build/suwc/OS12503560

Assignments to super[expr] where expr contains variable references
are not being applied to super property objects. Fix bytecode emitter.
  • Loading branch information
chakrabot committed Jul 21, 2017
1 parent 9c4761a commit 1114aad
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7106,9 +7106,16 @@ void EmitAssignment(

case knopIndex:
{
Js::RegSlot targetLocation =
(lhs->sxBin.pnode1->nop == knopSuper) ?
byteCodeGenerator->EmitLdObjProto(Js::OpCode::LdHomeObjProto, funcInfo->superRegister, funcInfo) :
lhs->sxBin.pnode1->location;

EmitSuperMethodBegin(lhs, byteCodeGenerator, funcInfo);
byteCodeGenerator->Writer()->Element(
ByteCodeGenerator::GetStElemIOpCode(funcInfo),
rhsLocation, lhs->sxBin.pnode1->location, lhs->sxBin.pnode2->location);
rhsLocation, targetLocation, lhs->sxBin.pnode2->location);

break;
}

Expand Down
27 changes: 27 additions & 0 deletions deps/chakrashim/core/test/es6/classes_bugfixes.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,33 @@ var tests = [
assert.areEqual('abc', result, "result == 'abc'");
}
},
{
name: "OS12503560: assignment to super[prop] not accessing base class property",
body: function () {
var result = "";
class B {
get x1() { result += "Bgetter;"; return 0; }
set x1(v){ result += "Bsetter;"; }
}

class A extends B {
constructor() {
(()=>{
super();
var s = 'x';
super[(s+s).substr(0,1)+1] = null;
s = super[s+'1'];
})();
}

get x1() { result += "Agetter;"; return 0; } // should not be called
set x1(v){ result += "Asetter;"; } // should not be called
};

new A();
assert.areEqual('Bsetter;Bgetter;', result);
}
},
];

testRunner.runTests(tests, { verbose: WScript.Arguments[0] != "summary" });
Expand Down

0 comments on commit 1114aad

Please sign in to comment.