-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed as duplicate of#58177
Closed as duplicate of#58177
Copy link
Labels
actorFeature → concurrency: `actor` declarationsFeature → concurrency: `actor` declarationsactor isolationFeature → concurrency: Actor isolationFeature → concurrency: Actor isolationbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featuresdefault argumentsFeature: default arguments for value parametersFeature: default arguments for value parametersswift 5.9type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysisunexpected errorBug: Unexpected errorBug: Unexpected error
Description
Description
When declaring a function with a global actor requirement, default values of its arguments are checked without that actor requirement.
Steps to reproduce
@MainActor
final class SomeClass {
static var someConstant: Int { 3 }
func someMethod(value: Int = SomeClass.someConstant) {}
}swiftc -strict-concurrency=complete mainactor-default.swift
Expected behavior
The code should compile, since the function must be called on the main actor, it should be OK for the default value of the argument to require the main actor too.
Actual behavior
mainactor-default.swift:6:44: error: main actor-isolated static property 'someConstant' can not be referenced from a non-isolated context
func someMethod(value: Int = SomeClass.someConstant) {}
^
mainactor-default.swift:4:16: note: static property declared here
static var someConstant: Int { 3 }
^
Environment
- swift-driver version: 1.62.15 Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)
Target: arm64-apple-macosx13.0 - Xcode 14.2
Build version 14C18
Metadata
Metadata
Assignees
Labels
actorFeature → concurrency: `actor` declarationsFeature → concurrency: `actor` declarationsactor isolationFeature → concurrency: Actor isolationFeature → concurrency: Actor isolationbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featuresdefault argumentsFeature: default arguments for value parametersFeature: default arguments for value parametersswift 5.9type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysisunexpected errorBug: Unexpected errorBug: Unexpected error