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

Browser version support in platform checks #1766

Open
MaxDesiatov opened this issue Sep 16, 2020 · 0 comments
Open

Browser version support in platform checks #1766

MaxDesiatov opened this issue Sep 16, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@MaxDesiatov
Copy link

MaxDesiatov commented Sep 16, 2020

When writing requirements for swiftwasm/JavaScriptKit#56, it reminded me of my old idea for browser version checks in Swift:

@available(Safari 14, Edge 79, Firefox 68, Chrome 67)
final class JSBigInt {
  //...
}

Then user code could look like:

if #available(Safari 14, Edge 79, Firefox 68, Chrome 67) {
  // code that uses `JSBigInt`
else {
  // backward-compatible code
}

Ideally, one would write:

if #available(JSBigInt) {
  // code that uses `JSBigInt`
else {
  // backward-compatible code
}

but this doesn't match the existing semantics of #available, which checks for platforms, not features. And making the toolchain aware of every feature is not realistic in my opinion. Besides, AFAIR Xcode (and hopefully SourceKit-LSP) fix-its propose adding corresponding platform version checks automatically after you attempt to use a "future" API when targeting older platforms.

@MaxDesiatov MaxDesiatov added the enhancement New feature or request label Sep 16, 2020
@kateinoigakukun kateinoigakukun moved this to To triage in Yuta's project Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant