Open
Description
Motivation
I was experimenting with some features from SE-420, and I made a typo. I found it quite hard to figure out what was going on from the error message produced. I have no idea if such a thing is possible to handle more gracefully, but I thought I'd point it out anyways.
protocol Thingy {
func doThing(isolation: isolated (any Actor)?)
}
actor MyActor {
var value = 1
}
extension Thingy {
func doThing(isolation: isolated (Any Actor)? = #isolation) {
print(value)
}
}
And here are the warnings being produced:
test.swift:10:45: error: expected ':' following argument label and parameter name
8 |
9 | extension Thingy {
10 | func doThing(isolation: isolated (Any Actor)? = #isolation) {
| `- error: expected ':' following argument label and parameter name
11 | print(value)
12 | }
test.swift:10:45: error: expected type
8 |
9 | extension Thingy {
10 | func doThing(isolation: isolated (Any Actor)? = #isolation) {
| `- error: expected type
11 | print(value)
12 | }
test.swift:10:26: error: 'isolated' parameter type '()?' does not conform to 'Actor' or 'DistributedActor'
8 |
9 | extension Thingy {
10 | func doThing(isolation: isolated (Any Actor)? = #isolation) {
| `- error: 'isolated' parameter type '()?' does not conform to 'Actor' or 'DistributedActor'
11 | print(value)
12 | }
test.swift:11:9: error: cannot find 'value' in scope
9 | extension Thingy {
10 | func doThing(isolation: isolated (Any Actor)? = #isolation) {
11 | print(value)
| `- error: cannot find 'value' in scope
12 | }
13 | }
Proposed solution
I think it would be great if I could get some feedback about the possibility that I just typoed here. Especially in this specific example, I think Any
is actually totally invalid. But, it would be even cooler if it could be solved more generally.
Alternatives considered
No response
Additional information
No response