Bug? Swift 5.10 and consume operator

error: 'consume' applied to value that the compiler does not support. This is a compiler bug. Please file a bug with a small example of the bug

func test() {
    var a = ""
    let b = consume a
}

Would you be able to check if your issue is already tracked on GitHub and file a new one if not? Issues · apple/swift · GitHub
Thanks!

it’s been a known issue since before the release:

2 Likes

This is because eager move support broke consume for eager move types. If you try it with something that isn't eager move it should work. That being said, we already fixed this in 9861422eeb57de43e9fbabd00aace5abac6d4701.

That fix is incomplete, since we still fail in the same way on ToT at least in cases where the initializer value is trivial (such as an empty string, nil for an optional, etc.) They might still be hitting LinearLifetimeCheckerPrivate.h: Error! Found a leaked owned value that was never consumed. · Issue #71608 · apple/swift · GitHub.

Fixed by a54a8ddaa381b039c3ef43e5baf5140ef86bcedc .

1 Like