Skip to content

Add missing imports of _RegexParser #763

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
Sep 24, 2024

Conversation

tshortli
Copy link
Contributor

While experimenting with adopting the MemberImportVisibility experimental feature (SE-0444) in the standard library build, I found that the _StringProcessing module was relying on transitive imports of _RegexParser in many source files.

@tshortli
Copy link
Contributor Author

@swift-ci please test

@@ -9,8 +9,8 @@
//
//===----------------------------------------------------------------------===//

@_spi(_Unicode)
import Swift
@_spi(_Unicode) import Swift
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer the attribute to appear on a newline above the import.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. How do you see this style mixing with multiple imports in the same file? To me this looked rather unusual and made it hard to scan the block of imports. I could also add a newline before internal import _RegexParser but that too looks unusual.

Copy link
Contributor

Choose a reason for hiding this comment

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

My personal preference for attributes is always above the declaration it's attributing to. In the standard library for functions we have:

@available(SwiftStdlib 6.0, *)
func something() {
}

right, and for property wrappers my preference is also above the property declaration:

struct A {
  @propertyWrapper
  let b: Int

  let c: String
}

I think the newline before the 2nd property here makes sense to me and would similarly apply it to imports:

@attribute
import Swift

import A
import B

But again, this is just personal preference. I don't think we have a defined style yet for this because we just simply don't write imports with attributes often at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I generally agree that attributes belong above declarations, especially when the list of attributes is likely to grow and line lengths can become an issue. For whatever reason, though, vibes-wise I don't think of imports as following the same rules as other declarations because it's so common for there to be an uninterrupted block of them at the top of a file. @_spi on a separate line really sticks out like a sore thumb to me, never seen it outside of this codebase. I'll follow your recommendation here, though, as I agree it seems to be the most consistent rule.

While experimenting with adopting the `MemberImportVisibility` experimental
feature (SE-0444) in the standard library build, I found that the
`_StringProcessing` module was relying on transitive imports of `_RegexParser`
in many source files.
@tshortli tshortli force-pushed the missing-regex-parser-imports branch from 3449927 to f6e4f7e Compare September 24, 2024 17:31
@tshortli
Copy link
Contributor Author

@swift-ci please test

@tshortli tshortli merged commit ce8f124 into swiftlang:main Sep 24, 2024
2 checks passed
@tshortli tshortli deleted the missing-regex-parser-imports branch September 24, 2024 17:45
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