1/* 2 * Copyright (c) 2024-2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 17function foo1 (tuple: readonly [number, string, boolean], arr: readonly int[]) { 18 let x: readonly [number, string] = [1, "a"] 19 let x2: readonly [string, double] 20 let y: readonly int[] = [] 21 let y2: readonly string[] 22} 23function foo2 (px: readonly int[], py: readonly [string, float]) { 24 let x2 : readonly int[] = px 25 let y2 : readonly [string, float] = py 26} 27 28function foo3 (x: readonly int[], x2: int[]) { 29 x = [1, 2] 30 x = new int[10] 31 let y: int[] = [] 32 x = y 33 x = x2 34} 35 36function foo4 (x: readonly [int, string], x2: [int, string]) { 37 x = [1, "abc"] 38 let y : [int, string] = [1, "abc"] 39 x = y 40 x = x2 41} 42 43 44function main() : void { 45 foo1([1, "ab", true], [1, 2]) 46 let x2: readonly int[] = [] 47 let y2: readonly [string, float] = ["a", Double.toFloat(0.1)] 48 foo2(x2, y2) 49 50 let x : readonly int[] = [] 51 x = [1, 2] 52 let y : readonly [int, string] = [1, "abc"] 53 y = [10, "cde"] 54 foo3([1, 2], [1, 2]) 55 foo4([1, "xx"], [1, "xx"]) 56}