diff --git a/es2panda/binder/scope.cpp b/es2panda/binder/scope.cpp index 9ee64ef6881aa9d746df67bc160af07d4eb630cd..17ba3df8e8ed2ce5b02a849ec650d44d2af3835e 100644 --- a/es2panda/binder/scope.cpp +++ b/es2panda/binder/scope.cpp @@ -123,7 +123,7 @@ ScopeFindResult Scope::Find(const util::StringView &name, ResolveBindingOptions if (iter->IsVariableScope()) { level++; - if (iter->IsFunctionScope()) { + if (iter->IsFunctionScope() && !crossConcurrent) { crossConcurrent = iter->Node()->AsScriptFunction()->IsConcurrent() ? true : false; } diff --git a/es2panda/test/parser/concurrent/using-mutable-lexical-variable-4-expected.txt b/es2panda/test/parser/concurrent/using-mutable-lexical-variable-4-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..80b0902093bfb278a33c66afe4c4fb4d0f969bf7 --- /dev/null +++ b/es2panda/test/parser/concurrent/using-mutable-lexical-variable-4-expected.txt @@ -0,0 +1,2 @@ +Error: Concurrent function should only use import variable or local variable [using-mutable-lexical-variable-4.js:21:15] +the size of programs is expected to be 1, but is 0 diff --git a/es2panda/test/parser/concurrent/using-mutable-lexical-variable-4.js b/es2panda/test/parser/concurrent/using-mutable-lexical-variable-4.js new file mode 100644 index 0000000000000000000000000000000000000000..2f55230006d65a5de37cb0ef7c57754069c2c704 --- /dev/null +++ b/es2panda/test/parser/concurrent/using-mutable-lexical-variable-4.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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. + */ + +"use strict"; +let a = 1; + +function b() { + function c() { + "use concurrent"; + return a; + } +}