Skip to content

[SE-0290] Add #unavailable (Negative platform checks) #33932

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 2 commits into from
Jul 13, 2021

Conversation

rockbruno
Copy link
Contributor

@rockbruno rockbruno commented Sep 13, 2020

@theblixguy theblixguy added the swift evolution pending discussion Flag → feature: A feature that has a Swift evolution proposal currently in review label Sep 13, 2020
@rockbruno rockbruno force-pushed the negative-aval branch 2 times, most recently from fab737a to 291bfef Compare September 13, 2020 12:21
@rockbruno rockbruno changed the title [SE-XXXX] Add #unavailable (Negative platform checks) [SE-NNNN] Add #unavailable (Negative platform checks) Sep 13, 2020
@shahmishal
Copy link
Member

Please update the base branch to main by Oct 5th otherwise the pull request will be closed automatically.

  • How to change the base branch: (Link)
  • More detail about the branch update: (Link)

@rockbruno rockbruno changed the base branch from master to main October 1, 2020 06:22
@rockbruno rockbruno changed the title [SE-NNNN] Add #unavailable (Negative platform checks) [SE-0290] Add #unavailable (Negative platform checks) Nov 4, 2020
@rockbruno
Copy link
Contributor Author

I notice now that that the underlying _stdlib_isOSVersionAtLeast emission needs to be reverted as well. I'll add this change along with some SIL tests as the review progresses.

@rockbruno rockbruno force-pushed the negative-aval branch 3 times, most recently from 5d6780a to 04bf875 Compare November 12, 2020 19:59
@rockbruno
Copy link
Contributor Author

I updated the implementation to match the final revision (imply the wildcard). The implementation now rejects explicit *s and injecting a fake one to the spec list so that the rest of the logic works as expected.

I was unsure how to proceed with #unavailable() though. This is technically correct if the wildcard is implied but right now it's being rejected by the parser.

@theblixguy theblixguy added swift evolution approved Flag → feature: A feature that was approved through the Swift evolution process and removed swift evolution pending discussion Flag → feature: A feature that has a Swift evolution proposal currently in review labels Apr 15, 2021
@rockbruno
Copy link
Contributor Author

@tkremenek Any updates on the plan for this feature? I'd like to keep the branch updated, but only when this actually moves forward.

@varungandhi-apple
Copy link
Contributor

Sorry this got missed. Could you please fix the merge conflicts? I've left some comments and have asked other folks to chime in as well.

In the future, please feel free to ping someone who has modified the surrounding code for review, or ask on the Swift forums for review.

@varungandhi-apple
Copy link
Contributor

cc @rintaro for parser changes, cc @amartini51 as there may be potential TSPL changes.

@rockbruno
Copy link
Contributor Author

Thanks @varungandhi-apple! I'll rebase it and apply the changes.

@rockbruno
Copy link
Contributor Author

rockbruno commented Jun 12, 2021

@varungandhi-apple I've updated it. Had to lose the commit history though because it was 3000 commits behind main 😢

Comment on lines 798 to 799
auto makeResult = ^(Optional<AvailabilityContext> TrueRefinement,
Optional<AvailabilityContext> FalseRefinement) {
Copy link
Contributor

@varungandhi-apple varungandhi-apple Jun 29, 2021

Choose a reason for hiding this comment

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

Nit: Please use C++ lambda syntax instead of using block syntax. (I'm not sure if MSVC supports the latter, also we use lambda syntax with [ ... ] elsewhere in the code.)

Comment on lines 826 to 828
auto Queries = available->getQueries();

for (auto *Spec : Queries) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't look like Queries is getting used later.

Suggested change
auto Queries = available->getQueries();
for (auto *Spec : Queries) {
for (auto *Spec : available->getQueries()) {

Copy link
Contributor

@varungandhi-apple varungandhi-apple left a comment

Choose a reason for hiding this comment

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

Thanks for your patience with the review. Mostly LGTM, left a couple of minor comments. You may want to squash some of the later commits.

@varungandhi-apple
Copy link
Contributor

@swift-ci smoke test

@rockbruno
Copy link
Contributor Author

@varungandhi-apple There was a typo in the result builder logic, I cleaned it up further and squashed the rest.

@varungandhi-apple
Copy link
Contributor

@swift-ci smoke test

@rockbruno
Copy link
Contributor Author

Hm it failed because of SwiftSyntax not knowing the keyword, do I need to push something in its repo first for it to pass here?

@ahoppen
Copy link
Member

ahoppen commented Jul 1, 2021

Hm it failed because of SwiftSyntax not knowing the keyword, do I need to push something in its repo first for it to pass here?

You need to re-generate the files in the SwiftSyntax repo. For this:

  • Check out https://github.com/apple/swift-syntax next to your swift repository
  • Run ./build-script.py --toolchain /path/to/anywhere --degyb-only in the swift-syntax repository
  • Set up a PR to the swift-syntax repository and mention it in this PR
  • Not to people triggering CI: You need to reference the corresponding swift-syntax PR when testing swift and the swift PR when testing swift-syntax like here. Also the two PRs need to be merged at the same time.

@rockbruno
Copy link
Contributor Author

@ahoppen Thanks! I tried that but I get errors about python imports. Do I need a specific python version?

    from .Classification import classification_by_name
ImportError: attempted relative import with no known parent package

@ahoppen
Copy link
Member

ahoppen commented Jul 2, 2021

I haven’t seen that error message before. I’m using Python 2. Could you share the entire error message? Maybe I’ll be able to figure out what’s going on from there.

@rockbruno
Copy link
Contributor Author

With Python 2, I get a slightly different error:

** Generating gyb Files **
Traceback (most recent call last):
  File "/Users/rochab/Desktop/Other/swift-sources/swift/utils/gyb", line 3, in <module>
    gyb.main()
  File "/Users/rochab/Desktop/Other/swift-sources/swift/utils/gyb.py", line 1267, in main
    f.write(execute_template(ast, args.line_directive, **bindings))
  File "/Users/rochab/Desktop/Other/swift-sources/swift/utils/gyb.py", line 1137, in execute_template
    ast.execute(execution_context)
  File "/Users/rochab/Desktop/Other/swift-sources/swift/utils/gyb.py", line 639, in execute
    x.execute(context)
  File "/Users/rochab/Desktop/Other/swift-sources/swift/utils/gyb.py", line 725, in execute
    result = eval(self.code, context.local_bindings)
  File "/Users/rochab/Desktop/Other/swift-sources/swift-syntax/Sources/SwiftSyntaxBuilder/Buildables.swift.gyb", line 5, in <module>
    from gyb_syntax_support.kinds import syntax_buildable_child_type, syntax_buildable_default_init_value
ImportError: cannot import name syntax_buildable_default_init_value
FAIL: Generating .gyb files failed

@ahoppen
Copy link
Member

ahoppen commented Jul 2, 2021

That’s probably because syntax_buildable_default_init_value was added fairly recently (~1 month ago) in b7d4dec. Could you try rebasing your swift branch?

@rockbruno
Copy link
Contributor Author

Should've tried that first. It worked, thanks!

swiftlang/swift-syntax#296

@ahoppen
Copy link
Member

ahoppen commented Jul 2, 2021

Nice! Let’s see what CI has to say now.

swiftlang/swift-syntax#296
@swift-ci Please smoke test

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.

Changes to gyb_syntax_support are looking good to me. I didn’t look at the other changes.

@varungandhi-apple
Copy link
Contributor

@swift-ci test and merge

@rockbruno
Copy link
Contributor Author

rockbruno commented Jul 13, 2021

I think we need to merge swiftlang/swift-syntax#296 first for this to become green, right?

@ahoppen
Copy link
Member

ahoppen commented Jul 13, 2021

You need to merge them at the same time. Make sure that both have a green CI status before merging either.

@rockbruno
Copy link
Contributor Author

rockbruno commented Jul 13, 2021

Ah I see, it failed because we needed to reference the PR in the command.

@ahoppen
Copy link
Member

ahoppen commented Jul 13, 2021

Yeah, so they've always been tested in unison in PR testing so far (because you referenced the other PR) and thus you also need to merge them together.

@varungandhi-apple
Copy link
Contributor

My bad, sorry about that. I should've paid more attention.

swiftlang/swift-syntax#296

@swift-ci please test

@varungandhi-apple varungandhi-apple merged commit db35cab into swiftlang:main Jul 13, 2021
@varungandhi-apple
Copy link
Contributor

@rockbruno could you submit a PR adding a "Swift Next" entry to the ChangeLog and mentioning this new feature there? Here's an example PR which does that.

@rockbruno
Copy link
Contributor Author

Done: #38390

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
swift evolution approved Flag → feature: A feature that was approved through the Swift evolution process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants