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/* @@ label */,/* @@ label1 */) { 17 return number[0] 18} 19 20function foo2(number,) { 21 return number 22} 23 24function foo3(/* @@ label2 */, number) { 25 return number 26} 27 28let a = [1, , 2,,] // OK - omitted expressions 29foo(...a,) 30foo(a[0],) 31foo(a[0], a[1], ...a,) 32foo(a[0],/* @@ label3 */,a[0]) 33foo(a[0],/* @@ label4 */,) 34foo(/* @@ label5 */,a[0]) 35foo(a[0] /* @@ label6 */a[1]/* @@ label7 */) 36foo(/* @@ label8 */,) 37 38 39/* @@@ label Error SyntaxError: Rest parameter must be the last formal parameter. */ 40/* @@@ label1 Error SyntaxError: Unexpected token, expected '{'. */ 41/* @@@ label2 Error SyntaxError: Unexpected token. */ 42/* @@@ label3 Error SyntaxError: Unexpected token ','. */ 43/* @@@ label4 Error SyntaxError: Unexpected token ','. */ 44/* @@@ label5 Error SyntaxError: Unexpected token ','. */ 45/* @@@ label6 Error SyntaxError: Unexpected token, expected ',' or ')'. */ 46/* @@@ label6 Error SyntaxError: Unexpected token 'a'. */ 47/* @@@ label7 Error SyntaxError: Unexpected token ')'. */ 48/* @@@ label8 Error SyntaxError: Unexpected token ','. */ 49/* @@@ label9 Error SyntaxError: Expected '}', got 'end of stream'. */ 50/* @@ label9 */