Skip to content

Commit 71d4e12

Browse files
rerobikadbatyai
authored andcommitted
Fix assignment opcode transformation for CBC_PUSH_THIS_LITERAL (#3525)
This patch fixes #3477. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
1 parent c494893 commit 71d4e12

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

jerry-core/parser/js/js-parser-expr.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2177,6 +2177,13 @@ parser_append_binary_single_assignment_token (parser_context_t *context_p, /**<
21772177
parser_stack_push_uint16 (context_p, literal_index);
21782178
parser_stack_push_uint8 (context_p, assign_ident_opcode);
21792179
}
2180+
else if (context_p->last_cbc_opcode == CBC_PUSH_THIS_LITERAL)
2181+
{
2182+
context_p->last_cbc_opcode = CBC_PUSH_THIS;
2183+
parser_flush_cbc (context_p);
2184+
parser_stack_push_uint16 (context_p, context_p->last_cbc.literal_index);
2185+
parser_stack_push_uint8 (context_p, assign_ident_opcode);
2186+
}
21802187
else if (context_p->last_cbc_opcode == CBC_PUSH_PROP)
21812188
{
21822189
JERRY_ASSERT (CBC_SAME_ARGS (CBC_PUSH_PROP, CBC_ASSIGN));
@@ -2270,6 +2277,12 @@ parser_append_binary_token (parser_context_t *context_p) /**< context */
22702277
{
22712278
context_p->last_cbc_opcode = PARSER_PUSH_PROP_TO_PUSH_PROP_REFERENCE (context_p->last_cbc_opcode);
22722279
}
2280+
else if (context_p->last_cbc_opcode == CBC_PUSH_THIS_LITERAL)
2281+
{
2282+
context_p->last_cbc_opcode = CBC_PUSH_THIS;
2283+
parser_flush_cbc (context_p);
2284+
context_p->last_cbc_opcode = CBC_PUSH_IDENT_REFERENCE;
2285+
}
22732286
else
22742287
{
22752288
/* Invalid LeftHandSide expression. */
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright JS Foundation and other contributors, http://js.foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
function _p(arg1, arg2) {
16+
return arg1 ? arg1 : arg2;
17+
}
18+
19+
var _ref;
20+
var constructor = _p(this, (_ref = Object.getPrototypeOf(function (){})).call({}));
21+
assert(constructor === this);
22+
23+
try {
24+
_p(this, (_ref += Object.getPrototypeOf(function (){})).call({}));
25+
assert(false);
26+
} catch (e) {
27+
assert(e instanceof TypeError);
28+
}

0 commit comments

Comments
 (0)