File tree Expand file tree Collapse file tree 2 files changed +81
-0
lines changed Expand file tree Collapse file tree 2 files changed +81
-0
lines changed Original file line number Diff line number Diff line change
1
+ // RUN: %target-jit-run %s -enable-experimental-feature LazyImmediate | %FileCheck %s
2
+
3
+ // Tests that parsing of function bodies is deferred
4
+ // to runtime when the interpreter is invoked using
5
+ // experimental lazy compilation. Syntax errors in
6
+ // functions not executed at runtime should be ignored.
7
+
8
+ public func foo( ) {
9
+ 3 +
10
+ }
11
+
12
+ // Syntax error in `foo` should be ignored
13
+
14
+ // CHECK: hello
15
+ print ( " hello " )
16
+
17
+ public func bar( _ b: Bool ) {
18
+ if b {
19
+ print ( " bar " )
20
+ } else {
21
+ foo ( )
22
+ }
23
+ }
24
+
25
+ // Function `foo` with syntax error is not executed
26
+ // by bar, so the type error should again be ignored
27
+
28
+ // CHECK: bar
29
+ bar ( true )
30
+
31
+ public func add( _ x: Int , _ y: Int , _ z: Int ) -> Int {
32
+ return x + y + z
33
+ }
34
+
35
+ public func sub( _ x: Int , _ y: Int ) -> Int {
36
+ return add( x,
37
+ }
38
+
39
+ // CHECK: 6
40
+ print ( add ( 1 , 2 , 3 ) )
41
+
Original file line number Diff line number Diff line change
1
+ // RUN: %target-jit-run %s -enable-experimental-feature LazyImmediate | %FileCheck %s
2
+
3
+ // Tests that type checking of function bodies is
4
+ // deferred to runtime when the interpreter is invoked
5
+ // using experimental lazy compilation. Type errors in
6
+ // functions not executed at runtime should be ignored.
7
+
8
+ public func foo( ) {
9
+ 3 + true
10
+ }
11
+
12
+ // Type error in `foo` should be ignored
13
+
14
+ // CHECK: hello
15
+ print ( " hello " )
16
+
17
+ public func bar( _ b: Bool ) {
18
+ if b {
19
+ print ( " bar " )
20
+ } else {
21
+ foo ( )
22
+ }
23
+ }
24
+
25
+ // Function `foo` with type error is not executed
26
+ // by bar, so the type error should again be ignored
27
+
28
+ // CHECK: bar
29
+ bar ( true )
30
+
31
+ public func add( _ x: Int , _ y: Int , _ z: Int ) -> Int {
32
+ return x + y + z
33
+ }
34
+
35
+ public func sub( _ x: Int , _ y: Int ) -> Int {
36
+ return add ( x, - y)
37
+ }
38
+
39
+ // CHECK: 6
40
+ print ( add ( 1 , 2 , 3 ) )
You can’t perform that action at this time.
0 commit comments