Skip to content

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Apr 21, 2021

Because we are completing inside a result builder, we are never calling into typeCheckExpression and thus never call into typeCheckForCodeCompletion before fallbackTypeCheck (I filed SR-14601 to track that issue).

This works fine in most cases, but in the added test case, we are hitting an assertion because the specifiers are not correctly erased from the ClosureExpr before re-typechecking for completion. Erasing them before fixes the test case until the underlying issue described above is fixed.

Fixes rdar://76710904 [SR-14494]

@ahoppen ahoppen requested a review from xedin April 21, 2021 15:18
@ahoppen
Copy link
Member Author

ahoppen commented Apr 21, 2021

@swift-ci Please test

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.

This situation would have to be fixed in the solver to prevent bindings inferring a l-value for T10.

struct BottomMenu: MyView {
var body: some MyView {
let a = MyZStack(alignment: .#^COMPLETE^#center, content: {})
.my_updating(body: { state in
Copy link
Contributor

Choose a reason for hiding this comment

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

So here is the interesting thing about this example - original type-check of this expression succeeds and produces a well-formed call. But then typeCheckForCodeCompletion called on type-checked AST and it seems not all of the information is erased. Why does that expression get re-typechecked that's probably where the investigation should start...

…n for completion

Because we are completing inside a result builder, we are never calling into `typeCheckExpression` and thus never call into `typeCheckForCodeCompletion` before `fallbackTypeCheck` (SR-14601).

This works fine in most cases, but in the added test case, we are hitting an assertion because the specifiers are not correctly erased from the `ClosureExpr` before re-typechecking for completion. Erasing them before fixes the test case until the underlying issue described above is fixed.

Fixes rdar://76710904 [SR-14494]
@ahoppen ahoppen changed the title [TypeChecker] Fix assertion failure wrapping an LValue type in another LValue [TypeChecker] Clear param specifiers before re-typechecking expression for completion May 6, 2021
@ahoppen ahoppen force-pushed the pr/wrapping-lvalue branch from aebab69 to b1a4708 Compare May 6, 2021 08:00
@ahoppen
Copy link
Member Author

ahoppen commented May 6, 2021

@xedin Thanks for your feedback. I adjusted the PR to clear the specifiers of closure expression parameters, which fixes the test case in a more principled way.

There seems to be a general issue with result builders that causes all expressions in there to be re-typechecked, because we are never calling into typeCheckExpression while type checking the result builder. Because that’s probably a larger fix (at least with more impact), I would suggest that we merge this PR as-is (might be useful in other cases where we need to fall back as well) and look at the result builder issue in another PR.

@ahoppen
Copy link
Member Author

ahoppen commented May 6, 2021

@swift-ci Please test

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