mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Fix local variable declaration issues after function argument initialization. (#3304)
Fixes #3298 Fixes #3299 Fixes #3300 Fixes #3302 JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
parent
b16b400d5b
commit
419ccff611
@ -303,13 +303,13 @@
|
||||
CBC_OPCODE (CBC_EVAL, CBC_NO_FLAG, 0, \
|
||||
VM_OC_EVAL) \
|
||||
CBC_OPCODE (CBC_CREATE_LOCAL, CBC_HAS_LITERAL_ARG, 0, \
|
||||
VM_OC_NONE) \
|
||||
VM_OC_INIT_LOCALS) \
|
||||
CBC_OPCODE (CBC_CREATE_LET, CBC_HAS_LITERAL_ARG, 0, \
|
||||
VM_OC_NONE) \
|
||||
VM_OC_INIT_LOCALS) \
|
||||
CBC_OPCODE (CBC_CREATE_CONST, CBC_HAS_LITERAL_ARG, 0, \
|
||||
VM_OC_NONE) \
|
||||
VM_OC_INIT_LOCALS) \
|
||||
CBC_OPCODE (CBC_INIT_LOCAL, CBC_HAS_LITERAL_ARG | CBC_HAS_LITERAL_ARG2, 0, \
|
||||
VM_OC_NONE) \
|
||||
VM_OC_INIT_LOCALS) \
|
||||
CBC_OPCODE (CBC_CREATE_VAR_EVAL, CBC_HAS_LITERAL_ARG, 0, \
|
||||
VM_OC_NONE) \
|
||||
CBC_OPCODE (CBC_CREATE_VAR_FUNC_EVAL, CBC_HAS_LITERAL_ARG | CBC_HAS_LITERAL_ARG2, 0, \
|
||||
|
||||
@ -1312,6 +1312,13 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
continue;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
case VM_OC_INIT_LOCALS:
|
||||
{
|
||||
frame_ctx_p->byte_code_p = byte_code_start_p;
|
||||
vm_init_loop (frame_ctx_p);
|
||||
byte_code_p = frame_ctx_p->byte_code_p;
|
||||
continue;
|
||||
}
|
||||
case VM_OC_ASSIGN_LET_CONST:
|
||||
{
|
||||
uint32_t literal_index;
|
||||
@ -3424,6 +3431,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
continue;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_LINE_INFO) */
|
||||
case VM_OC_NONE:
|
||||
default:
|
||||
{
|
||||
JERRY_ASSERT (VM_OC_GROUP_GET_INDEX (opcode_data) == VM_OC_NONE);
|
||||
|
||||
@ -202,9 +202,7 @@ typedef enum
|
||||
VM_OC_RIGHT_SHIFT, /**< right shift */
|
||||
VM_OC_UNS_RIGHT_SHIFT, /**< unsigned right shift */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
VM_OC_BLOCK_CREATE_CONTEXT, /**< create lexical environment for blocks enclosed in braces */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
VM_OC_WITH, /**< with */
|
||||
VM_OC_FOR_IN_CREATE_CONTEXT, /**< for in create context */
|
||||
VM_OC_FOR_IN_GET_NEXT, /**< get next */
|
||||
@ -220,11 +218,14 @@ typedef enum
|
||||
VM_OC_BREAKPOINT_ENABLED, /**< enabled breakpoint for debugger */
|
||||
VM_OC_BREAKPOINT_DISABLED, /**< disabled breakpoint for debugger */
|
||||
#endif /* ENABLED (JERRY_DEBUGGER) */
|
||||
#if ENABLED (JERRY_LINE_INFO)
|
||||
#if ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
VM_OC_RESOURCE_NAME, /**< resource name of the current function */
|
||||
#endif /* ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#if ENABLED (JERRY_LINE_INFO)
|
||||
VM_OC_LINE, /**< line number of the next statement */
|
||||
#endif /* ENABLED (JERRY_LINE_INFO) */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
VM_OC_INIT_LOCALS, /**< call vm_init_loop() */
|
||||
VM_OC_ASSIGN_LET_CONST, /**< assign values to let/const declarations */
|
||||
VM_OC_CLONE_CONTEXT, /**< clone lexical environment with let/const declarations */
|
||||
VM_OC_SET_COMPUTED_PROPERTY, /**< set computed property */
|
||||
@ -260,15 +261,17 @@ typedef enum
|
||||
VM_OC_BREAKPOINT_ENABLED = VM_OC_NONE, /**< enabled breakpoint for debugger is unused */
|
||||
VM_OC_BREAKPOINT_DISABLED = VM_OC_NONE, /**< disabled breakpoint for debugger is unused */
|
||||
#endif /* !ENABLED (JERRY_DEBUGGER) */
|
||||
#if !ENABLED (JERRY_LINE_INFO)
|
||||
#if !ENABLED (JERRY_LINE_INFO) && !ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
VM_OC_RESOURCE_NAME = VM_OC_NONE, /**< resource name of the current function is unused */
|
||||
#endif /* !ENABLED (JERRY_LINE_INFO) && !ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#if !ENABLED (JERRY_LINE_INFO)
|
||||
VM_OC_LINE = VM_OC_NONE, /**< line number of the next statement is unused */
|
||||
#endif /* !ENABLED (JERRY_LINE_INFO) */
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
VM_OC_INIT_LOCALS = VM_OC_NONE, /**< call vm_init_loop() */
|
||||
VM_OC_ASSIGN_LET_CONST = VM_OC_NONE, /**< assign values to let/const declarations */
|
||||
VM_OC_CLONE_CONTEXT = VM_OC_NONE, /**< clone lexical environment with let/const declarations */
|
||||
VM_OC_SET_COMPUTED_PROPERTY = VM_OC_NONE, /**< set computed property is unused */
|
||||
VM_OC_BLOCK_CREATE_CONTEXT = VM_OC_NONE, /**< create context for blocks enclosed in braces */
|
||||
|
||||
VM_OC_FOR_OF_CREATE_CONTEXT = VM_OC_NONE, /**< for of create context */
|
||||
VM_OC_FOR_OF_GET_NEXT = VM_OC_NONE, /**< get next */
|
||||
|
||||
@ -63,3 +63,19 @@ function j(a = arguments[1])
|
||||
assert(a === 2);
|
||||
}
|
||||
j(undefined,2);
|
||||
|
||||
function k(a = 2)
|
||||
{
|
||||
let d = 5;
|
||||
assert(d === 5);
|
||||
eval("assert(a === 2)");
|
||||
}
|
||||
k();
|
||||
|
||||
function i(a = 3)
|
||||
{
|
||||
const d = 6;
|
||||
assert(d === 6);
|
||||
eval("assert(a === 3)");
|
||||
}
|
||||
i();
|
||||
|
||||
22
tests/jerry/es2015/regression-test-issue-3298.js
Normal file
22
tests/jerry/es2015/regression-test-issue-3298.js
Normal file
@ -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 $ = { $: function ( $) { } };
|
||||
|
||||
function g ( b = (local = $) ) {
|
||||
var o ;
|
||||
function f ( ) { return this === o }
|
||||
}
|
||||
|
||||
g ()
|
||||
26
tests/jerry/es2015/regresssion-test-issue-3302.js
Normal file
26
tests/jerry/es2015/regresssion-test-issue-3302.js
Normal file
@ -0,0 +1,26 @@
|
||||
// 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.
|
||||
|
||||
function g ( a, b = a ) {
|
||||
function a ( ) { }
|
||||
function $ ( ) { }
|
||||
eval ( "" )
|
||||
}
|
||||
g ( );
|
||||
|
||||
$ = function ( ) {
|
||||
function x ( ) { }
|
||||
}
|
||||
|
||||
function j ( ) { }
|
||||
27
tests/jerry/fail/regresssion-test-issue-3299.js
Normal file
27
tests/jerry/fail/regresssion-test-issue-3299.js
Normal file
@ -0,0 +1,27 @@
|
||||
// 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.
|
||||
|
||||
function f (a, b = $+ function ( ) { } ( ), $) { }
|
||||
var $ = { $: function ($) { }}
|
||||
f( )
|
||||
|
||||
function duplicatedArg ( a , b = d , c ) {
|
||||
try {
|
||||
var eval
|
||||
var id_1
|
||||
if ( id_2 === eval ( ) ) { }
|
||||
} finally { }
|
||||
}
|
||||
|
||||
duplicatedArg(1, 2)
|
||||
23
tests/jerry/fail/regresssion-test-issue-3300.js
Normal file
23
tests/jerry/fail/regresssion-test-issue-3300.js
Normal file
@ -0,0 +1,23 @@
|
||||
// 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.
|
||||
|
||||
y = 6
|
||||
function i ( a , b = ( y ) + 2 , c = typeof id_0 ) {
|
||||
function x ( ) { }
|
||||
eval ( "//Single Line Comments\u2029 var =;" )
|
||||
c === "undefined"
|
||||
print ( y === 10 )
|
||||
( id_2 === 11 )
|
||||
}
|
||||
i ( )
|
||||
Loading…
x
Reference in New Issue
Block a user