Swift version
swift-driver version: 1.148.6 Apple Swift version 6.3.2 (swiftlang-6.3.2.1.108 clang-2100.1.1.101)
Platform
arm64-apple-macosx26.0
Editor
Visual Studio Code
Description
I'm working on code that is enabled by a trait, and cannot get sourcekit-lsp to provide editor support for code that is inside regions that are conditionally included via traits.
Here is my locally set .sourcekit-lsp/config.json:
{
"swiftPM": {
"traits": ["libpkl", "libpkl_shared"]
}
}
Here's a reproducer branch; focus on file LibPklClient.swift:
https://github.com/bioball/pkl-swift/tree/sourcekit-bug
Trying to compile with swift build --traits libpkl,libpkl_shared produces error:
Building for debugging...
/Users/danielchao/code/apple/pkl-swift/Sources/PklSwift/LibPkl/LibPklClient.swift:69:14: error: value of type 'LibPklClient' has no member 'foobar'
67 |
68 | // nonsense; `foobar` doesn't exist on `self`
69 | self.foobar = "hi"
| `- error: value of type 'LibPklClient' has no member 'foobar'
70 |
71 | let context = ResponseContext(continuation: continuation)
[6/9] Compiling PklSwift LibPklClient.swift
However, VSCodes doesn't highlight this error. Also, other basic things don't work, e.g. go-to definition.
Steps to Reproduce
- Clone this branch https://github.com/bioball/pkl-swift/tree/sourcekit-bug
- Add this file to
.sourcekit-lsp/config.json:
{
"swiftPM": {
"traits": ["libpkl", "libpkl_shared"]
}
}
- Navigate to
LibPklClient.swift inside Visual Studio Code, and find that the editor isn't showing any error diagnostics, and other things don't work either (e.g. go-to-definition)
NOTE: running swift build produces errors as expected:
Building for debugging...
/Users/danielchao/code/apple/pkl-swift/Sources/PklSwift/LibPkl/LibPklClient.swift:69:14: error: value of type 'LibPklClient' has no member 'foobar'
67 |
68 | // nonsense; `foobar` doesn't exist on `self`
69 | self.foobar = "hi"
| `- error: value of type 'LibPklClient' has no member 'foobar'
70 |
71 | let context = ResponseContext(continuation: continuation)
[6/9] Compiling PklSwift LibPklClient.swift
Logging
No response
Swift version
swift-driver version: 1.148.6 Apple Swift version 6.3.2 (swiftlang-6.3.2.1.108 clang-2100.1.1.101)
Platform
arm64-apple-macosx26.0
Editor
Visual Studio Code
Description
I'm working on code that is enabled by a trait, and cannot get sourcekit-lsp to provide editor support for code that is inside regions that are conditionally included via traits.
Here is my locally set
.sourcekit-lsp/config.json:{ "swiftPM": { "traits": ["libpkl", "libpkl_shared"] } }Here's a reproducer branch; focus on file
LibPklClient.swift:https://github.com/bioball/pkl-swift/tree/sourcekit-bug
Trying to compile with
swift build --traits libpkl,libpkl_sharedproduces error:However, VSCodes doesn't highlight this error. Also, other basic things don't work, e.g. go-to definition.
Steps to Reproduce
.sourcekit-lsp/config.json:LibPklClient.swiftinside Visual Studio Code, and find that the editor isn't showing any error diagnostics, and other things don't work either (e.g. go-to-definition)NOTE: running
swift buildproduces errors as expected:Logging
No response