Compiler hang on consuming in noncopyable enum with URL in associated value?

Am I doing something wrong here? (e.g. Is there some extra syntax I'm supposed to provide to hint the compiler so it can complete?) Or should I file a bug somewhere?

Given:

enum MyEnum: ~Copyable{
    case nothing
    case myUrl(URL)
}

Xcode compiler runs forever:

func foo(_ bar: consuming MyEnum) {
    switch consume bar {
    case .nothing:
        return
    case .myUrl(let url):
        return
    }
}

Xcode compile completes:

func foo(_ bar: consuming MyEnum) {
    switch consume bar {
    case .nothing:
        return
    default:
        return
    }
}

If I change URL to String or even NSURL it's happy.

Ahah, if i try this:

func foo(_ bar: consuming MyEnum) {
    switch consume bar {
    case .nothing:
        return
    case .myUrl(_):
        return
    }
}

I get: Usage of a noncopyable type that compiler can't verify. This is a compiler bug. Please file a bug with a small example of the bug

Filed feedback through Xcode with MRE -- ticket # is FB14982645

Should I file issue at bugs.swift.org too?

2 Likes

Thanks for tracking this down! It definitely looks like a bug. An Apple feedback report is sufficient, though the public bug tracker might let us give more direct feedback than Apple's official channels.

1 Like