diff --git a/jerry-core/parser/js/js-parser-expr.c b/jerry-core/parser/js/js-parser-expr.c index 8a77aa63e..48b7b919c 100644 --- a/jerry-core/parser/js/js-parser-expr.c +++ b/jerry-core/parser/js/js-parser-expr.c @@ -178,7 +178,7 @@ parser_emit_ident_reference (parser_context_t *context_p, /**< context */ else if (context_p->last_cbc_opcode == CBC_PUSH_THIS_LITERAL) { context_p->last_cbc_opcode = CBC_PUSH_THIS; - literal_index = context_p->lit_object.index; + literal_index = context_p->last_cbc.literal_index; } else { @@ -1946,7 +1946,7 @@ parser_process_unary_expression (parser_context_t *context_p, /**< context */ } #endif /* ENABLED (JERRY_ES2015) */ else if (JERRY_UNLIKELY (context_p->status_flags & PARSER_INSIDE_WITH) - && PARSER_IS_PUSH_LITERAL (context_p->last_cbc_opcode) + && PARSER_IS_PUSH_LITERALS_WITH_THIS (context_p->last_cbc_opcode) && context_p->last_cbc.literal_type == LEXER_IDENT_LITERAL) { opcode = CBC_CALL_PROP; @@ -2193,7 +2193,7 @@ parser_process_unary_expression (parser_context_t *context_p, /**< context */ if (token == CBC_TYPEOF) { - if (PARSER_IS_PUSH_LITERAL (context_p->last_cbc_opcode) + if (PARSER_IS_PUSH_LITERALS_WITH_THIS (context_p->last_cbc_opcode) && context_p->last_cbc.literal_type == LEXER_IDENT_LITERAL) { parser_emit_ident_reference (context_p, CBC_TYPEOF_IDENT); @@ -2365,7 +2365,7 @@ parser_append_binary_token (parser_context_t *context_p) /**< context */ if (LEXER_IS_BINARY_LVALUE_TOKEN (context_p->token.type)) { - if (PARSER_IS_PUSH_LITERAL (context_p->last_cbc_opcode) + if (PARSER_IS_PUSH_LITERALS_WITH_THIS (context_p->last_cbc_opcode) && context_p->last_cbc.literal_type == LEXER_IDENT_LITERAL) { parser_check_invalid_assign (context_p); @@ -2376,12 +2376,6 @@ parser_append_binary_token (parser_context_t *context_p) /**< context */ { context_p->last_cbc_opcode = PARSER_PUSH_PROP_TO_PUSH_PROP_REFERENCE (context_p->last_cbc_opcode); } - else if (context_p->last_cbc_opcode == CBC_PUSH_THIS_LITERAL) - { - context_p->last_cbc_opcode = CBC_PUSH_THIS; - parser_flush_cbc (context_p); - context_p->last_cbc_opcode = CBC_PUSH_IDENT_REFERENCE; - } else { /* Invalid LeftHandSide expression. */ diff --git a/tests/jerry/arithmetic-parse.js b/tests/jerry/arithmetic-parse.js index a8cf687ed..15544bc99 100644 --- a/tests/jerry/arithmetic-parse.js +++ b/tests/jerry/arithmetic-parse.js @@ -56,10 +56,37 @@ function f() { try { eval ("g(this, 'a' = 1)"); - assert (false) + assert (false); } catch (e) { assert (e instanceof ReferenceError); } + + try { + eval ("g(this, 'a' += 1)"); + assert (false); + } catch (e) { + assert (e instanceof ReferenceError); + } + assert (a === 0); } f(); + +function g(a, b) +{ + assert(b === "undefined"); +} +g(this, typeof undeclared_var) + +function h() +{ + var done = false; + var o = { a: function () { done = (this === o) } } + function f() {} + + with (o) { + f(this, a()); + } + assert(done); +} +h();