Fix "Invalid prefix operation" errors (#4577)

`--(-a);` returned with a postfix error before this patch.
The changes introduce a new warning for prefix errors, and
returns with the corresponding one based on current opcode.

JerryScript-DCO-1.0-Signed-off-by: Bela Toth tbela@inf.u-szeged.hu
This commit is contained in:
Tóth Béla
2021-02-08 16:13:37 +01:00
committed by GitHub
parent b1f73e698a
commit 35ecf4c4a3
3 changed files with 13 additions and 1 deletions
+8 -1
View File
@@ -302,7 +302,14 @@ parser_emit_unary_lvalue_opcode (parser_context_t *context_p, /**< context */
#if JERRY_ESNEXT
parser_check_invalid_new_target (context_p, opcode);
parser_raise_error (context_p, PARSER_ERR_INVALID_LHS_POSTFIX_OP);
if (opcode == CBC_PRE_INCR || opcode == CBC_PRE_DECR)
{
parser_raise_error (context_p, PARSER_ERR_INVALID_LHS_PREFIX_OP);
}
else
{
parser_raise_error (context_p, PARSER_ERR_INVALID_LHS_POSTFIX_OP);
}
#else /* JERRY_ESNEXT */
parser_emit_cbc_ext (context_p, CBC_EXT_THROW_REFERENCE_ERROR);
#endif /* JERRY_ESNEXT */