Skip to content

Invalid async call in default initialized parameter #73892

Closed
@mattmassicotte

Description

@mattmassicotte

Description

This code successfully compiles with the 2024-05-14 6.0 development snapshot in both Swift 5 and Swift 6 mode.

I'm fairly sure that Swift 5.10's error is correct and this code should be invalid.

Reproduction

@MainActor
func doThing(_ value: Int) {
}

class SomeThing {
	let task = Task {
		doThing(42)
	}
}

Expected behavior

With swift 5.10:

swift -enable-experimental-feature StrictConcurrency test.swift
test.swift:7:3: error: expression is 'async' but is not marked with 'await'
                doThing(42)
                ^~~~~~~~~~~
                await 
test.swift:7:3: note: calls to global function 'doThing' from outside of its actor context are implicitly asynchronous
                doThing(42)
                ^

Environment

swift-6.0-DEVELOPMENT-SNAPSHOT-2024-05-14-a

Apple Swift version 6.0-dev (LLVM 5b202efbc95a8bf, Swift a17d360)
Target: arm64-apple-macosx14.0

Additional information

No response

Metadata

Metadata

Assignees

Labels

accepts invalidBug: Accepts invalidactor isolationFeature → concurrency: Actor isolationbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresregressionswift 6.0type checkerArea → compiler: Semantic analysis

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions