1/* 2 * Copyright (c) 2023 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 */ 15declare function print(arg:any):void; 16 17function tryHello(v: number): void { 18 let a: number = 1; 19 let ret: number = a + v; 20 print(ret); 21} 22 23tryHello(<number><Object>'a'); 24 25 26function tryIf(v: number, b: number): void { 27 let a : number = 1; 28 29 if (b == 1) { 30 let ret: number = a + v; 31 print(ret); 32 } 33} 34tryIf(<number><Object>'a', 1); 35 36function tryPhi(v: number, b: number): void { 37 let a : number = 1; 38 let ret: number = 1; 39 if (b == 1) { 40 ret = a + v; 41 } 42 print(ret); 43} 44 45tryPhi(<number><Object>'a', 1); 46 47function tryLoop(v: number, b: number): void { 48 let a : number = 1; 49 let ret: number = 1; 50 51 for (var i = 0; i < b; i++) { 52 ret = a + v; 53 } 54 print(ret); 55} 56 57tryLoop(<number><Object>'a', 1); 58