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 16function foo(...number: int[],): int { 17 return number[0] 18} 19 20function foo2(number: int,): int { 21 return number 22} 23 24function foo3(, number: int): int { 25 return number 26} 27 28let a = [1,, 2,] 29foo(...a,) 30foo(a[0],) 31foo(a[0], a[1], ...a,) 32foo(a[0],,a[0]) 33foo(a[0],,) 34foo(,a[0]) 35foo(a[0] a[1]) 36foo(,) 37 38/* @@? 16:30 Error SyntaxError: Rest parameter must be the last formal parameter. */ 39/* @@? 24:15 Error SyntaxError: Unexpected token, expected an identifier. */ 40/* @@? 24:15 Error SyntaxError: Parameter declaration should have an explicit type annotation. */ 41/* @@? 28:12 Error SyntaxError: Unexpected token ','. */ 42/* @@? 28:14 Error SyntaxError: Unexpected token, expected ',' or ']'. */ 43/* @@? 28:14 Error SyntaxError: Unexpected token '2'. */ 44/* @@? 28:15 Error SyntaxError: Unexpected token ','. */ 45/* @@? 28:16 Error SyntaxError: Unexpected token ']'. */ 46/* @@? 30:5 Error TypeError: Indexed access is not supported for such expression type. */ 47/* @@? 31:1 Error TypeError: No matching call signature for foo(a[0], a[1], ...a) */ 48/* @@? 31:5 Error TypeError: Indexed access is not supported for such expression type. */ 49/* @@? 31:11 Error TypeError: Indexed access is not supported for such expression type. */ 50/* @@? 31:17 Error TypeError: Spread argument for the rest parameter can be only one. */ 51/* @@? 32:5 Error TypeError: Indexed access is not supported for such expression type. */ 52/* @@? 32:10 Error SyntaxError: Unexpected token ','. */ 53/* @@? 32:11 Error SyntaxError: Unexpected token, expected ',' or ')'. */ 54/* @@? 32:11 Error SyntaxError: Unexpected token 'a'. */ 55/* @@? 32:11 Error TypeError: Indexed access is not supported for such expression type. */ 56/* @@? 32:15 Error SyntaxError: Unexpected token ')'. */ 57/* @@? 33:5 Error TypeError: Indexed access is not supported for such expression type. */ 58/* @@? 33:10 Error SyntaxError: Unexpected token ','. */ 59/* @@? 34:5 Error SyntaxError: Unexpected token ','. */ 60/* @@? 34:6 Error SyntaxError: Unexpected token 'a'. */ 61/* @@? 34:6 Error SyntaxError: Unexpected token, expected ',' or ')'. */ 62/* @@? 34:6 Error TypeError: Indexed access is not supported for such expression type. */ 63/* @@? 34:10 Error SyntaxError: Unexpected token ')'. */ 64/* @@? 35:5 Error TypeError: Indexed access is not supported for such expression type. */ 65/* @@? 35:10 Error SyntaxError: Unexpected token 'a'. */ 66/* @@? 35:10 Error SyntaxError: Unexpected token, expected ',' or ')'. */ 67/* @@? 35:10 Error TypeError: Indexed access is not supported for such expression type. */ 68/* @@? 35:14 Error SyntaxError: Unexpected token ')'. */ 69/* @@? 36:5 Error SyntaxError: Unexpected token ','. */ 70