~Copyable: what is it good for?

i found one really hacky way to get this working:

struct Server:~Copyable
{
    private
    let loop:ServerLoop
    let state:Server.State
}
extension Server
{
    var count:Counters
    {
        _read { yield self.loop.count }
    }
}

the compiler admits it doesn’t know how to compile this.

copy of noncopyable typed value. This is a compiler bug. Please file a bug with a small example of the bug

but i managed to trick it into compiling it anyway using immediately-executed closures.

let n:Int =
{
    (count:borrowing Counters) in

    count.foosBarred.load(ordering: .relaxed)

} (server.count)

who knows what demons i may have unleashed by doing this…

perhaps ~Copyable is not ready for prime time.

1 Like