Skip to content

Support for isolated and async deinit #1656

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
Jun 16, 2023

Conversation

nickolas-pohilets
Copy link

@nickolas-pohilets nickolas-pohilets force-pushed the mpokhylets/async-deinit branch from 95e8c60 to 40a0bf0 Compare June 11, 2023 13:33
@nickolas-pohilets nickolas-pohilets marked this pull request as ready for review June 11, 2023 14:23
@ahoppen
Copy link
Member

ahoppen commented Jun 12, 2023

Thanks for the PR @nickolas-pohilets and for thinking so much about the recovery case. The test cases look really good 🌟 . I’m just wondering if we could simplify the implementation a little bit. It feels overly complicated to me at the moment.

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

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

This looks really good. I’ve got a few minor comments but all of them should be fairly minor.

) {
// Inserted missing throws is discarded
assert(throwsSpecifier?.isMissing ?? true)
assert(unexpectedAfterThrowsSpecifier == nil)
Copy link
Member

Choose a reason for hiding this comment

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

This worries me a little bit because I’m not entirely sure that we really always end up with this being nil but can’t come up with a counter example from the top of my head. I would feel more comfortable if we just combine it with unexpectedBetweenAsyncSpecifierAndThrowsSpecifier.

RawUnexpectedNodesSyntax(combining: unexpectedBetweenAsyncSpecifierAndThrowsSpecifier, unexpectedAfterThrowsSpecifier, arena: arena),

Copy link
Author

Choose a reason for hiding this comment

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

At this point we have only a single case (as noted in the extension comment), where we know that unexpectedAfterThrowsSpecifier cannot appear. Combining two groups of unexpected syntax looses information, which was affecting how exchangeTokens() behaves. Not sure if it still does after loosening the checks. But I would postpone combining or any other handling logic until other cases appear.

Copy link
Member

Choose a reason for hiding this comment

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

I’m mostly thinking that the assumption that unexpectedAfterThrowsSpecifier is empty might change in the future. And especially the recovery cases are not hit as frequently in CI but more infrequently while code is being edited, so we might not actually notice that the assertion starts being violated. Thus, I’d rather be safe here.

And I don’t see how RawUnexpectedNodesSyntax(combining:) can change the layout of the node if unexpectedAfterThrowsSpecifier is nil because it just grabs the elements of unexpectedBetweenAsyncSpecifierAndThrowsSpecifier and puts them in a new RawUnexpectedNodesSyntax.

Copy link
Author

@nickolas-pohilets nickolas-pohilets Jun 15, 2023

Choose a reason for hiding this comment

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

IMO, this entire conformance is hacky, and I would advise against introducing any new cases relying on it. I think even with RawUnexpectedNodesSyntax(combining:) implementation of the initialiser would be not robust enough to work in the general case. It is still not possible to pass RawDeinitEffectSpecifiersSyntax to parseEffectSpecifiers().

Cleaner solution would be create a new protocol just for the parseMisplacedEffectSpecifiers(). I've pushed an update. @ahoppen, WDYT?

@nickolas-pohilets nickolas-pohilets force-pushed the mpokhylets/async-deinit branch from e053d3b to 7cef632 Compare June 14, 2023 22:28
@nickolas-pohilets
Copy link
Author

Rebased after #1767

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

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

I really like the newly introduced protocol 😍 That’s a lot cleaner than everything we had before. Thanks for the idea.

I’ve got two really minor comments, otherwise this looks good to me now. Thanks for your great collaboration on this PR.

@nickolas-pohilets
Copy link
Author

Should this MR and swiftlang/swift#60057 be merged in any specific order? I was getting failing tests in the main repo without changes in this one, so I guess this MR needs to be merged first. Or neither can be merged until proposal is approved?

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

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

Nice. Thanks for your effort! One last request: Could you squash your commits? It just makes for a nicer commit history.

@nickolas-pohilets nickolas-pohilets force-pushed the mpokhylets/async-deinit branch from 1751c0b to 5cf3d86 Compare June 15, 2023 18:17
@nickolas-pohilets
Copy link
Author

@swift-ci, please test

@nickolas-pohilets
Copy link
Author

@swift-ci please test

@nickolas-pohilets
Copy link
Author

@ahoppen, could you please trigger CI? Looks like I don’t have rights. Or what am I doing wrong?

@ahoppen
Copy link
Member

ahoppen commented Jun 16, 2023

Yes, you need push access to trigger CI for security reasons. Triggering it now.

@swift-ci Please test

@ahoppen ahoppen enabled auto-merge June 16, 2023 10:46
@ahoppen
Copy link
Member

ahoppen commented Jun 16, 2023

@swift-ci Please test Windows

@nickolas-pohilets
Copy link
Author

nickolas-pohilets commented Jun 16, 2023

CI failed because of this:

FAIL: code-generated files committed to repository do not match generated ones.

When I try to regenerate them, I get the following error:

CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/KeywordFile.swift:18:48: error: type 'TokenSyntax' has no member 'leftSquareToken'
let lookupTable = ArrayExprSyntax(leftSquare: .leftSquareToken(trailingTrivia: .newline)) {
                                              ~^~~~~~~~~~~~~~~

Reproduces on fresh main branch. @ahoppen, looks like main is broken.

Looks like issue was introduced in a862613, parent ccc812e works fine for me.

auto-merge was automatically disabled June 16, 2023 12:32

Head branch was pushed to by a user without write access

@nickolas-pohilets nickolas-pohilets force-pushed the mpokhylets/async-deinit branch from 5cf3d86 to 538af36 Compare June 16, 2023 12:32
@nickolas-pohilets
Copy link
Author

git clean -fdx helped. Could it be that ./build-script.py generate-source-code incorrectly caches code generator binary?

I've pushed an update, let's re-try CI

@ahoppen
Copy link
Member

ahoppen commented Jun 16, 2023

Yes, we’re currently seeing issues with CodeGeneration not updating correctly. We haven’t had the chance to 100% pinpoint the failure point. There was a discussion going on here: #1741 (comment)

@ahoppen ahoppen enabled auto-merge June 16, 2023 12:53
@ahoppen
Copy link
Member

ahoppen commented Jun 16, 2023

@swift-ci Please test

@ahoppen ahoppen merged commit 526958d into swiftlang:main Jun 16, 2023
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