Replies: 1 comment 3 replies
-
|
Hi @ylorn, @Test func foo() {
struct S {
var x: Int {
get { fatalError() }
set { }
}
}
var s = S()
s.x = 42
set(&s, keyPath: \.x, value: 44) // 💥
}
func set<R, V>(_ root: inout R, keyPath: WritableKeyPath<R, V>, value: V) {
root[keyPath: keyPath] = value
}The getter is called when setting However, I also don't think what you are doing in this code snippet is necessary. The @DependencyClient
struct ProblemClient: Sendable {
var invoke: @Sendable () -> Void
}
extension ProblemClient: TestDependencyKey {
static let testValue = ProblemClient()
}
struct ProblemTests {
@Test func reproduce() async throws {
@Dependency(ProblemClient.self) var problemClient
problemClient.invoke()
// 🛑 Issue recorded: Unimplemented: 'ProblemClient.invoke'
}
}The macro created an initializer for So I believe the library is worked as intended. Since this isn't an issue with the library I am going to convert it to a discussion. Please feel free to continue the conversation over there! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
Using following code as an example:
Checklist
mainbranch of this package.Expected behavior
No response
Actual behavior
No response
Steps to reproduce
When testing with
error occurs:
However, if I changed the test traits:
The test passed, and the original issue no longer occurs.
Why is different API giving different results? Aren't they supposed to function the same?
Dependencies version information
1.10.0
Destination operating system
macOS 26.0.1
Xcode version information
Xcode 26.0.1
Swift Compiler version information
Beta Was this translation helpful? Give feedback.
All reactions