Fix "arguments" and "eval" parsing (#2661)
This patch fixes #2656 and fixes #2659 as well. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
committed by
László Langó
parent
98aa08e33c
commit
c305d70b11
@@ -1764,7 +1764,8 @@ lexer_construct_literal_object (parser_context_t *context_p, /**< context */
|
|||||||
&& memcmp (source_p + 1, "rgument", 7) == 0)
|
&& memcmp (source_p + 1, "rgument", 7) == 0)
|
||||||
{
|
{
|
||||||
context_p->lit_object.type = LEXER_LITERAL_OBJECT_ARGUMENTS;
|
context_p->lit_object.type = LEXER_LITERAL_OBJECT_ARGUMENTS;
|
||||||
if (!(context_p->status_flags & PARSER_ARGUMENTS_NOT_NEEDED))
|
if (!(context_p->status_flags & PARSER_ARGUMENTS_NOT_NEEDED)
|
||||||
|
&& literal_type == LEXER_IDENT_LITERAL)
|
||||||
{
|
{
|
||||||
context_p->status_flags |= PARSER_ARGUMENTS_NEEDED | PARSER_LEXICAL_ENV_NEEDED;
|
context_p->status_flags |= PARSER_ARGUMENTS_NEEDED | PARSER_LEXICAL_ENV_NEEDED;
|
||||||
context_p->lit_object.literal_p->status_flags |= LEXER_FLAG_NO_REG_STORE;
|
context_p->lit_object.literal_p->status_flags |= LEXER_FLAG_NO_REG_STORE;
|
||||||
|
|||||||
@@ -1546,9 +1546,9 @@ parser_process_unary_expression (parser_context_t *context_p) /**< context */
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (context_p->last_cbc_opcode == CBC_PUSH_LITERAL
|
if (context_p->last_cbc_opcode == CBC_PUSH_LITERAL
|
||||||
&& context_p->last_cbc.literal_object_type == LEXER_LITERAL_OBJECT_EVAL)
|
&& context_p->last_cbc.literal_object_type == LEXER_LITERAL_OBJECT_EVAL
|
||||||
|
&& context_p->last_cbc.literal_type == LEXER_IDENT_LITERAL)
|
||||||
{
|
{
|
||||||
JERRY_ASSERT (context_p->last_cbc.literal_type == LEXER_IDENT_LITERAL);
|
|
||||||
context_p->status_flags |= PARSER_ARGUMENTS_NEEDED | PARSER_LEXICAL_ENV_NEEDED | PARSER_NO_REG_STORE;
|
context_p->status_flags |= PARSER_ARGUMENTS_NEEDED | PARSER_LEXICAL_ENV_NEEDED | PARSER_NO_REG_STORE;
|
||||||
is_eval = true;
|
is_eval = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright JS Foundation and other contributors, http://js.foundation
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
`eval`("eval ('super (a, b, c)')");
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
// Copyright JS Foundation and other contributors, http://js.foundation
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
var obj = { "arguments": "foo" }
|
||||||
|
|
||||||
|
function testcase ()
|
||||||
|
{
|
||||||
|
return obj.hasOwnProperty ("arguments");
|
||||||
|
}
|
||||||
|
|
||||||
|
assert (testcase () === true);
|
||||||
Reference in New Issue
Block a user