diff --git a/static_core/plugins/ets/tests/ets-templates/08.statements/04.local_declarations/local_declaration_access_n.ets b/static_core/plugins/ets/tests/ets-templates/08.statements/04.local_declarations/local_declaration_access_n.ets new file mode 100644 index 0000000000000000000000000000000000000000..bd9213cfb82ba972dab17956029b502cc2fce44c --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/08.statements/04.local_declarations/local_declaration_access_n.ets @@ -0,0 +1,36 @@ +/*--- +Copyright (c) 2021-2025 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. +---*/ + +{% for c in cases %} +/*--- +desc: Local declaration - use a name declared in another block. +tags: [compile-only, negative] +---*/ + +function add5(b: int): int { + {{c.decl}} a: int = 5; + let i: int = a + b; + return i; +} + +function main(): void { + let j: int = 0; + { + {{c.decl}} k = 7; + j = add5(k); + } + let y = {{c.name}}; +} +{% endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/08.statements/04.local_declarations/local_declaration_access_n.params.yaml b/static_core/plugins/ets/tests/ets-templates/08.statements/04.local_declarations/local_declaration_access_n.params.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a60cdb66000fba716e90f1c27bb96edc0959ee5a --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/08.statements/04.local_declarations/local_declaration_access_n.params.yaml @@ -0,0 +1,19 @@ +# Copyright (c) 2025 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. + +--- +cases: + - { decl: 'let', name: a } + - { decl: 'const', name: a } + - { decl: 'let', name: k } + - { decl: 'const', name: k } diff --git a/static_core/plugins/ets/tests/ets-templates/08.statements/04.local_declarations/post_declaration_func_n.ets b/static_core/plugins/ets/tests/ets-templates/08.statements/04.local_declarations/post_declaration_func_n.ets new file mode 100644 index 0000000000000000000000000000000000000000..732a71e0dbf384b78ca7437d718c43f90c0ac9a2 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/08.statements/04.local_declarations/post_declaration_func_n.ets @@ -0,0 +1,31 @@ +/*--- +Copyright (c) 2021-2025 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. +---*/ + +{% for c in cases %} +/*--- +desc: Local declaration - use a name before declaration. +tags: [compile-only, negative] +---*/ + +function add5(b: int): int { + let i: int = a + b; + {{c.decl}} a: int = 5; + return i; +} + +function main(): void { + let y: int = add5(7); +} +{% endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/08.statements/04.local_declarations/post_declaration_func_n.params.yaml b/static_core/plugins/ets/tests/ets-templates/08.statements/04.local_declarations/post_declaration_func_n.params.yaml new file mode 100644 index 0000000000000000000000000000000000000000..bcb32ca5502bf120d2c8fabddd01e67c40940508 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/08.statements/04.local_declarations/post_declaration_func_n.params.yaml @@ -0,0 +1,17 @@ +# Copyright (c) 2025 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. + +--- +cases: + - decl: 'let' + - decl: 'const' diff --git a/static_core/plugins/ets/tests/ets-templates/08.statements/04.local_declarations/post_declaration_n.ets b/static_core/plugins/ets/tests/ets-templates/08.statements/04.local_declarations/post_declaration_n.ets new file mode 100644 index 0000000000000000000000000000000000000000..a159657db9fc0874bd5eac0fd03d72e512d78ee2 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/08.statements/04.local_declarations/post_declaration_n.ets @@ -0,0 +1,26 @@ +/*--- +Copyright (c) 2021-2025 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. +---*/ + +{% for c in cases %} +/*--- +desc: Local declaration - use name before declaration. +tags: [compile-only, negative] +---*/ + +function main(): void { + let b: int = a + 7; + {{c.decl}} a: int = 5; +} +{% endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/08.statements/04.local_declarations/post_declaration_n.params.yaml b/static_core/plugins/ets/tests/ets-templates/08.statements/04.local_declarations/post_declaration_n.params.yaml new file mode 100644 index 0000000000000000000000000000000000000000..bcb32ca5502bf120d2c8fabddd01e67c40940508 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/08.statements/04.local_declarations/post_declaration_n.params.yaml @@ -0,0 +1,17 @@ +# Copyright (c) 2025 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. + +--- +cases: + - decl: 'let' + - decl: 'const' diff --git a/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt b/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt index 1784c3645033ab27652092856014d787391fb2fd..4fa8e64d58c7d58de331f966ab8b8e9ad2116226 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt @@ -1246,6 +1246,10 @@ #23051 Reference comparison 07.expressions/25.equality_expressions/reference_equality/type_conversion_of_one_operand_to_another_type.ets +#29971 +08.statements/04.local_declarations/post_declaration_func_n_1.ets +08.statements/04.local_declarations/post_declaration_n_1.ets + #25042 Ast verifier failure for for-of with labelled statement 08.statements/11.continue_statements/continue_for_of3l.ets 08.statements/11.continue_statements/continue_for_of5l.ets