Files
swift-mirror/test/stdlib/ArraySlice.swift
Erik Eckstein f8ad7ade33 stdlib: fix the ArraySlice liverange dependency
Explicitly mark the dependency between the base pointer and the owner object.
Otherwise the owner object could be destroyed too early.
So far we got away with this because array semantic functions were not inlined in OSSA.

Fixes a miscompile.
2026-02-25 21:47:31 +01:00

26 lines
515 B
Swift

// RUN: %target-run-simple-swift(-O)
// REQUIRES: executable_test
// REQUIRES: reflection
import StdlibUnittest
let testSuite = TestSuite("ArraySlice")
@inline(never)
func getArray() -> [String] {
return [_opaqueIdentity("a very long string which is is not inlined")]
}
@inline(never)
func testSliceLiverange() -> String {
let a = getArray()
let s = a[0..<1]
return s[0]
}
testSuite.test("liverange") {
expectEqual(testSliceLiverange(), "a very long string which is is not inlined")
}
runAllTests()