Catch paramter must not be scanned as function in ES5.1 (#3618)

Fixes #3554

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg 2020-03-17 13:06:59 +01:00 committed by GitHub
parent 7ea93aff4c
commit 1cfda262bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 5 deletions

View File

@ -553,17 +553,26 @@ scanner_pop_literal_pool (parser_context_t *context_p, /**< context */
no_declarations++;
if (type & SCANNER_LITERAL_IS_FUNC)
{
no_declarations++;
}
if (no_reg || (type & no_reg_types))
{
type |= SCANNER_LITERAL_NO_REG;
literal_p->type = type;
}
if (type & SCANNER_LITERAL_IS_FUNC)
{
no_declarations++;
#if !ENABLED (JERRY_ES2015)
if (type & SCANNER_LITERAL_IS_LOCAL)
{
/* Catch parameters cannot be functions. */
literal_p->type = (uint8_t) (type & ~SCANNER_LITERAL_IS_FUNC);
no_declarations--;
}
#endif /* !ENABLED (JERRY_ES2015) */
}
intptr_t diff = (intptr_t) (literal_p->char_p - prev_source_p);
if (diff >= 1 && diff <= UINT8_MAX)

View 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 f() {
try {
assert(e() == 6)
throw 8;
assert(false);
} catch (e) {
function e() { return 6 }
assert(e == 8);
}
}
f();

View File

@ -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.
(function(){try{}catch(e){function e