Skip to content

Commit 774ba5e

Browse files
committed
Add a test for local variables inside of for loops inside of async functions.
rdar://105186946
1 parent 417f36c commit 774ba5e

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SWIFT_SOURCES := main.swift
2+
SWIFTFLAGS_EXTRAS := -parse-as-library
3+
include Makefile.rules
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import lldb
2+
from lldbsuite.test.decorators import *
3+
import lldbsuite.test.lldbtest as lldbtest
4+
import lldbsuite.test.lldbutil as lldbutil
5+
import unittest2
6+
7+
8+
class TestSwiftAsyncVariables(lldbtest.TestBase):
9+
10+
mydir = lldbtest.TestBase.compute_mydir(__file__)
11+
12+
@swiftTest
13+
@skipIf(oslist=['windows', 'linux'])
14+
def test(self):
15+
"""Test local variables in async functions"""
16+
self.build()
17+
src = lldb.SBFileSpec('main.swift')
18+
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
19+
self, 'break here', src)
20+
21+
while process.selected_thread.stop_reason == lldb.eStopReasonBreakpoint:
22+
self.expect("frame variable x", substrs=["23"])
23+
process.Continue()
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import Swift
2+
func use<T>(_ t: T) {}
3+
func sink<T>(_ t: T) {}
4+
5+
func split() async {}
6+
7+
func f(_ xs: [Int?]) async {
8+
for x in xs {
9+
let x = x!
10+
sink(x) // break here
11+
}
12+
await split()
13+
for x in xs {
14+
let x = x!
15+
sink(x) // break here
16+
}
17+
}
18+
19+
@main struct Main {
20+
static func main() async {
21+
await f([23])
22+
}
23+
}

0 commit comments

Comments
 (0)