diff --git a/jerry-core/parser/js/js-parser-expr.c b/jerry-core/parser/js/js-parser-expr.c index ee6e6298d..3630c6f41 100644 --- a/jerry-core/parser/js/js-parser-expr.c +++ b/jerry-core/parser/js/js-parser-expr.c @@ -2199,7 +2199,7 @@ parser_append_binary_single_assignment_token (parser_context_t *context_p, /**< uint8_t assign_opcode = CBC_ASSIGN; - 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) { JERRY_ASSERT (CBC_SAME_ARGS (CBC_PUSH_LITERAL, assign_ident_opcode)); @@ -2208,33 +2208,39 @@ parser_append_binary_single_assignment_token (parser_context_t *context_p, /**< uint16_t literal_index; - if (context_p->last_cbc_opcode == CBC_PUSH_LITERAL) + switch (context_p->last_cbc_opcode) { - literal_index = context_p->last_cbc.literal_index; - context_p->last_cbc_opcode = PARSER_CBC_UNAVAILABLE; - } - else if (context_p->last_cbc_opcode == CBC_PUSH_TWO_LITERALS) - { - literal_index = context_p->last_cbc.value; - context_p->last_cbc_opcode = CBC_PUSH_LITERAL; - } - else - { - JERRY_ASSERT (context_p->last_cbc_opcode == CBC_PUSH_THREE_LITERALS); - literal_index = context_p->last_cbc.third_literal_index; - context_p->last_cbc_opcode = CBC_PUSH_TWO_LITERALS; + case CBC_PUSH_LITERAL: + { + literal_index = context_p->last_cbc.literal_index; + context_p->last_cbc_opcode = PARSER_CBC_UNAVAILABLE; + break; + } + case CBC_PUSH_TWO_LITERALS: + { + literal_index = context_p->last_cbc.value; + context_p->last_cbc_opcode = CBC_PUSH_LITERAL; + break; + } + case CBC_PUSH_THIS_LITERAL: + { + literal_index = context_p->last_cbc.literal_index; + context_p->last_cbc_opcode = CBC_PUSH_THIS; + parser_flush_cbc (context_p); + break; + } + default: + { + JERRY_ASSERT (context_p->last_cbc_opcode == CBC_PUSH_THREE_LITERALS); + literal_index = context_p->last_cbc.third_literal_index; + context_p->last_cbc_opcode = CBC_PUSH_TWO_LITERALS; + break; + } } parser_stack_push_uint16 (context_p, literal_index); assign_opcode = assign_ident_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); - parser_stack_push_uint16 (context_p, context_p->last_cbc.literal_index); - assign_opcode = assign_ident_opcode; - } else if (context_p->last_cbc_opcode == CBC_PUSH_PROP) { JERRY_ASSERT (CBC_SAME_ARGS (CBC_PUSH_PROP, CBC_ASSIGN)); diff --git a/tests/jerry/arithmetic-parse.js b/tests/jerry/arithmetic-parse.js index 6c60e8451..3532af5fc 100644 --- a/tests/jerry/arithmetic-parse.js +++ b/tests/jerry/arithmetic-parse.js @@ -42,5 +42,19 @@ parse ("a =% b"); parse ("c = a+"); parse ("c = a-"); -parse("a++\n()") -parse("a--\n.b") +parse("a++\n()"); +parse("a--\n.b"); + +function f() { + var a = 0; + function g() {} + + try { + eval ("g(this, 'a' = 1)"); + assert (false) + } catch (e) { + assert (e instanceof ReferenceError); + } + assert (a === 0); +} +f();