-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Package.swift diagnostics on wrong line #7688
Labels
Comments
Is this reproducible for errors in other files too, or only |
MaxDesiatov
pushed a commit
that referenced
this issue
Jul 19, 2024
…#7795) Fixes issue #7688 SwiftPM was implicitly prepending the manifest with 'import Foundation' for toolchains using Swift toolchain versions 5.7 and under. The original file itself was never overwritten, thus the diagnostics being reported would always present on the next line. This is a quick fix that appends the same line to the end of the manifest; doing so assures that the intended behaviour doesn't change, but allows for correct diagnostics to be reported. ### Motivation: Diagnostics would present on the incorrect line for Package.swift files using tools version 5.7 and under. ### Modifications: When evaluating the manifest, a temporary directory copies the contents of the manifest to a temporary file; rather than prepending the import to Foundation at the top of the file (causing all lines in the diagnostic reports to be off by one), append the import to the bottom of the temporary manifest when dealing with tools versions 5.7 and under. ### Result: The intended behaviour that requires users to explicitly import Foundation doesn't change for Swift versions 5.8 and up; diagnostics reported for Package.swift files for those using swift <= 5.7 will now show on the correct line.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it reproducible with SwiftPM command-line tools:
swift build
,swift test
,swift package
etc?Description
SwiftPM diagnostics for the Package.swift show up at a different line/column than SourceKit-LSP. In this picture the first diagnostics is from SourceKit and shows up at right place, but SwiftPM indicates the diagnostic is on the next line
Expected behavior
No response
Actual behavior
No response
Steps to reproduce
// swift-tools-version: 5.6
swift package resolve
Notice output:
As you can see in the picture above the line was line 9, so line is off by one, but the column seems right
Swift Package Manager version/commit hash
No response
Swift & OS version (output of
swift --version ; uname -a
)swift-driver version: 1.110 Apple Swift version 6.0 (swiftlang-6.0.0.4.52 clang-1600.0.21.1.3)
Target: arm64-apple-macosx15.0
The text was updated successfully, but these errors were encountered: