Skip to content

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented Jun 17, 2024

The issue is that the shorthand if let syntax injects an implicit expression: #40694 in ParseStmt and that the 'diagnoseUnhandledAsyncSite' explicitly avoids reporting errors in implicit expressions.

This patch "peeks" at the expression to notice this case, however perhaps we should mark this implicit expression in ParseStmt and then detect it explicitly.

Added some tests covering this as well as properly erroring out for the nonexistent syntax of shortand + awaiting which doesn't exist, and we properly error on it.

Resolves rdar://126169564

@ktoso ktoso force-pushed the wip-async-get-if-let branch 3 times, most recently from d078c46 to 81f601f Compare June 17, 2024 12:41
@ktoso
Copy link
Contributor Author

ktoso commented Jun 17, 2024

@swift-ci please smoke test

2 similar comments
@ktoso
Copy link
Contributor Author

ktoso commented Jun 18, 2024

@swift-ci please smoke test

@ktoso
Copy link
Contributor Author

ktoso commented Jun 18, 2024

@swift-ci please smoke test

@ktoso
Copy link
Contributor Author

ktoso commented Jun 19, 2024

@swift-ci please smoke test

@ktoso ktoso force-pushed the wip-async-get-if-let branch from 3fdd17e to 05e1cc1 Compare June 19, 2024 08:10
@ktoso
Copy link
Contributor Author

ktoso commented Jun 19, 2024

@swift-ci please smoke test

@ktoso
Copy link
Contributor Author

ktoso commented Jun 19, 2024

I'll look into removing the special casing previously added for the if let self here 22e4313 in a separate PR

@ktoso ktoso force-pushed the wip-async-get-if-let branch 2 times, most recently from 74a410f to 5a061ae Compare June 19, 2024 08:20
The issue is that the shorthand if let syntax injects an implicit
expression: swiftlang#40694 in ParseStmt and
that the 'diagnoseUnhandledAsyncSite' explicitly avoids reporting errors
in implicit expressions.

This change is that we don't mark the implicit declref code emitted by
the `if let prop` as implicit anymore, and this way the reporting works
out as expected.

Added some tests covering this as well as properly erroring out for the
nonexistent syntax of shortand + awaiting which doesn't exist, and we
properly error on it.

Resolves rdar://126169564
@ktoso ktoso force-pushed the wip-async-get-if-let branch from 5a061ae to 0d3a4b4 Compare June 19, 2024 08:20
@ktoso
Copy link
Contributor Author

ktoso commented Jun 19, 2024

@swift-ci please smoke test

@ktoso ktoso merged commit 8c5d9e2 into swiftlang:main Jun 19, 2024
@ktoso ktoso deleted the wip-async-get-if-let branch June 19, 2024 14:21
@ktoso
Copy link
Contributor Author

ktoso commented Jun 19, 2024

Thanks for the reviews @ahoppen @hamishknight !

// expected-warning@-1 {{immutable value 'result' was never used; consider replacing with '_' or removing it}}
// expected-note@-2 {{reference to async let 'result' is 'async'}}
if let result = result {} // expected-error {{expression is 'async' but is not marked with 'await'}} {{19-19=await }}
// expected-warning@-1 {{value 'result' was defined but never used; consider replacing with boolean test}}
// expected-note@-2 {{reference to async let 'result' is 'async'}}
if let result {} // expected-error {{expression is 'async' but is not marked with 'await'}} {{16-16= = await result}}
if let result {} // expected-error {{expression is 'async' but is not marked with 'await'}} {{10-10=await }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm this doesn't quite seem right, if let await result is invalid, right? Looks like this fix-it logic is relying on the implicitness to detect the shorthand binding, maybe we need a bit to track this after all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm true that’s wrong… I’ll look if there’s an easy fix… would like to prevent the crash asap but let me look at the bad fixit as well

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.

3 participants