rvsrvs
(rvsrvs)
1
Playing around with wrapping some of my value types in noncopyable types generated the following in a playground under Xcode 15.1b2:
struct A { }
let a = A()
@dynamicMemberLookup
struct Ref<S>: ~Copyable {
var value: S
subscript<T>(dynamicMember keyPath: KeyPath<S, T>) -> T {
value[keyPath: keyPath]
}
}
let refA = Ref(value: a)
This produces:
error: couldn't IRGen expression. Please enable the expression log by running "log enable lldb expr", then run the failing expression again, and file a bug report with the log output.
Not quite sure a) how to do that last step or b) if this is supposed to work at this point. Thoughts?
rvsrvs
(rvsrvs)
2
ok, weird behavior from a playground. Here's a more precise version from trying to compile as a command line tool on Mac:
struct A { var a: String }
@dynamicMemberLookup
struct Ref<S>: ~Copyable {
var value: S
init(value: S) {
self.value = value
}
subscript<T>(dynamicMember keyPath: KeyPath<S, T>) -> T {
value[keyPath: keyPath]
}
}
let a = A(a: "Yo")
let refA = Ref(value: a)
_ = refA.value.a
_ = refA.value[keyPath: \.a]
_ = refA.a
print("hello, world!")
The line using the dynamicMember produces:
Copy of noncopyable typed value. This is a compiler bug. Please file a bug with a small example of the bug
Is this supposed to work yet?
2 Likes
scanon
(Steve Canon)
3
Whether or not it's "supposed to work yet," it's worth a bug report. Any internal compiler diagnostic merits a bug report.
In this case, it appears to work on the nightly, so I think this has been fixed since 5.9 was cut? Compiler Explorer
CC @Joe_Groff @kavon
2 Likes