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-13566] SPM's swift tools version specification requires exactly 1 single space character after "//" #4499

Closed
WowbaggersLiquidLunch opened this issue Sep 18, 2020 · 3 comments
Assignees
Labels

Comments

@WowbaggersLiquidLunch
Copy link
Collaborator

Previous ID SR-13566
Radar None
Original Reporter @WowbaggersLiquidLunch
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug
Assignee @WowbaggersLiquidLunch
Priority Medium

md5: 95510fb6c4f0933086d339be5d484ac3

Issue Description:

This bug is about the first line in every Package.swift, e.g. // swift-tools-version:5.3.

Currently it only accept a single space character between "//" and "swift-tools-version:5.3". It should allow any number of any horizontal whitespace characters.

@WowbaggersLiquidLunch
Copy link
Collaborator Author

The code responsible for parsing this line is located at line 181 of swift-package-manager/Sources/PackageLoading/ToolsVersionLoader.swift, copied below:

// The regex to match swift tools version specification:
// * It should start with `//` followed by any amount of whitespace.
// * Following that it should contain the case insensitive string `swift-tools-version:`.
// * The text between the above string and `;` or string end becomes the tools version specifier.
static let regex = try! NSRegularExpression(
    pattern: "^// swift-tools-version:(.*?)(?:;.*|$)",
    options: [.caseInsensitive])

The regex intends to match "any amount of whitespace followed by //" (according to the comments in the code snippet above), but in its implementation, it matches only 1 space character.

This can be easily fixed, but I want to use this bug report to ask if it was a conscious design choice to allow only 1 space character, and shouldn't be changed.

@WowbaggersLiquidLunch
Copy link
Collaborator Author

Opened pull request #2937

@WowbaggersLiquidLunch
Copy link
Collaborator Author

resolved by apple/swift-package-manager#2937

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant