Skip to content

[Diagnostics] Add an educational note explaining closure type inference rules #28572

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

Merged
merged 1 commit into from
Dec 6, 2019

Conversation

owenv
Copy link
Contributor

@owenv owenv commented Dec 4, 2019

This note explains the difference in type inference between single expression and non-single expression closures. It is associated with the "unable to infer complex closure return type" diagnostic when descriptive diagnostics are enabled.

Once #28313 lands I'll be able to add educational notes support to the verifier and add a test to this PR.

…ce rules

This note explains the difference in type inference between single expression and
non-single expression closures. It is associated with the "unable to infer
complex closure return type" diagnostic.
@owenv
Copy link
Contributor Author

owenv commented Dec 4, 2019

cc @xedin , @hborla

Now that some more of the details around educational notes are sorted out I'm beginning to take a look at how they could supplement some of the more nuanced type inference diagnostics. It's still early days but I'd be interested in any feedback you have on the style & content of these.

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I think this puts the unable to infer complex ... diagnostic in a spotlight though. It would be great to try and rephrase it in a way that it tries to explain why the type can't be inferred just like this note does but much shorter :)

@xedin
Copy link
Contributor

xedin commented Dec 6, 2019

@swift-ci please smoke test

@xedin
Copy link
Contributor

xedin commented Dec 6, 2019

Type-checker doesn't even try to infer anything in this case and just rolls with the context...

@owenv
Copy link
Contributor Author

owenv commented Dec 6, 2019

@xedin I agree the short message could probably be improved. I had a hard time trying to come up with something better though. If I do, I'll add it in.

@xedin
Copy link
Contributor

xedin commented Dec 6, 2019

Sounds good!

@xedin xedin merged commit 8261300 into swiftlang:master Dec 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants