swiftlang / swift-package-manager

The Package Manager for the Swift Programming Language
Apache License 2.0
9.72k stars 1.34k forks source link

Package.swift diagnostics on wrong line #7688

Closed award999 closed 2 months ago

award999 commented 3 months ago

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

Screenshot 2024-06-19 at 1 12 31 PM

Expected behavior

No response

Actual behavior

No response

Steps to reproduce

  1. Set macOS platform to v13 in Package.swift
  2. Set swift tool version to 5.6: // swift-tools-version: 5.6
  3. Save file and swift package resolve

Notice output:

Screenshot 2024-06-19 at 2 01 58 PM

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

MaxDesiatov commented 3 months ago

Is this reproducible for errors in other files too, or only Package.swift?

award999 commented 3 months ago

Only seems to be this specific case in Package.swift, for example doing something like this put on the right line (22 like I'd expect):

Screenshot 2024-06-19 at 3 42 34 PM

All diagnostics from swiftc seem correct