Is this a compiler bug?
Yes, see SR-1528.
Perhaps it has been fixed in Swift 5?
No, not in the latest Swift 5.0 snapshot.