Skip to content
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

[SR-11037] Parser should check for the wrong kind of platform condition #53426

Closed
beccadax opened this issue Jun 28, 2019 · 7 comments
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers parser Area → compiler: The legacy C++ parser

Comments

@beccadax
Copy link
Contributor

Previous ID SR-11037
Radar None
Original Reporter @beccadax
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, Parser, StarterBug
Assignee @roop
Priority Medium

md5: f0eda31a231fbda1905bf0d463f540ff

Issue Description:

Suppose you write this:

#if os(simulator)
    ...
#endif

"simulator" is not a known OS, so Swift looks for the closest matching OSes and suggests them instead:

<stdin>:1:8: warning: unknown operating system for build configuration 'os'
<stdin>:1:8: note: did you mean 'macOS'?

But it might be better to suggest changing "os" to "targetEnvironment", since "targetEnvironment(simulator)" is a valid platform condition.

If you want to fix this, look for the call to checkPlatformConditionSupported() in ParseIfConfig.cpp. The easiest implementation would be to simply try each of the other platform condition kinds and attach an appropriate fix-it if any of them are valid, but it might be possible to do something more clever by modifying how checkPlatformConditionSupported() communicates suggestions back to its caller.

@roop
Copy link
Mannequin

roop mannequin commented Jul 4, 2019

herzka (JIRA User): Do you mind if I start working on this?

brentdax (JIRA User): Thanks for the detailed pointers. I'm thinking of checkPlatformConditionSupported() taking an additional PlatformConditionKind &suggestedKind arg to be able to return the "targetEnvironment" as suggestion. Am I on the right track?

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 4, 2019

Comment by David Herzka (JIRA)

@roop, I've already started working on it because it looked like a good starter task. I haven't contributed to Swift before and would like to start with something tractable like this. Is there a reason why you think you should work on it instead?

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 4, 2019

Comment by David Herzka (JIRA)

Sorry, I'm just trying to get involved for the first time, so I don't know the etiquette here. Have I owned this bug for too long without putting up a PR or update?

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 4, 2019

Comment by David Herzka (JIRA)

@roop, go for it. It's a holiday here anyway. I can find a new starter bug after the holiday.

@roop
Copy link
Mannequin

roop mannequin commented Jul 4, 2019

Thanks, herzka (JIRA User), I'll take this up.

I'm a first time contributor as well, and I don't know the etiquette either. I don't think you owned this too long – I just didn't know if you were working on it or not.

@roop
Copy link
Mannequin

roop mannequin commented Jul 5, 2019

brentdax (JIRA User), I opened a PR for this #25977 – please review.

@roop
Copy link
Mannequin

roop mannequin commented Jan 9, 2020

The PR is merged to master and will likely be part of Swift 5.2.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers parser Area → compiler: The legacy C++ parser
Projects
None yet
Development

No branches or pull requests

2 participants