Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typo of any vs Any resulted in an unhelpful error message #73928

Open
mattmassicotte opened this issue May 27, 2024 · 0 comments
Open

Typo of any vs Any resulted in an unhelpful error message #73928

mattmassicotte opened this issue May 27, 2024 · 0 comments
Labels
diagnostics QoI Bug: Diagnostics Quality of Implementation parser Area → compiler: The legacy C++ parser

Comments

@mattmassicotte
Copy link
Contributor

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

@mattmassicotte mattmassicotte added feature A feature request or implementation triage needed This issue needs more specific labels labels May 27, 2024
@hborla hborla added diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis parser Area → compiler: The legacy C++ parser and removed feature A feature request or implementation triage needed This issue needs more specific labels type checker Area → compiler: Semantic analysis labels Jul 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
diagnostics QoI Bug: Diagnostics Quality of Implementation parser Area → compiler: The legacy C++ parser
Projects
None yet
Development

No branches or pull requests

2 participants