Files
swift-mirror/test/decl/var/lazy_properties_effects.swift
Allan Shortlidge cb578172ea Tests: Remove -disable-availability-checking in more tests that use concurrency.
Use the `%target-swift-5.1-abi-triple` substitution to compile the tests for
deployment to the minimum OS versions required for use of _Concurrency APIs,
instead of disabling availability checking.
2024-10-19 12:35:20 -07:00

18 lines
843 B
Swift

// RUN: %target-typecheck-verify-swift -target %target-swift-5.1-abi-triple
// We could make this work by having `lazy` synthesize an effectful
// getter, but for now let's reject it instead of crashing.
func throwsFunc() throws -> Int { return 3 }
func asyncFunc() async -> Int { return 3 }
func localLazyWithEffects() {
lazy var x = try throwsFunc() // expected-error {{call can throw, but errors cannot be thrown out of a lazy variable initializer}}
lazy var y = await asyncFunc() // expected-error {{'async' call cannot occur in a lazy variable initializer}}
}
struct InstanceLazyWithEffects {
lazy var x = try throwsFunc() // expected-error {{call can throw, but errors cannot be thrown out of a property initializer}}
lazy var y = await asyncFunc() // expected-error {{'async' call cannot occur in a property initializer}}
}