mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Fix invalid / unhandled this_literal cases. (#3696)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
parent
4e8dac8ce1
commit
f254b1a8b7
@ -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. */
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user