makeLibrary doesn’t report warnings on successful compile

I’m working with Metal on iPad Playgrounds and made a simple editor to help craft shaders. Press a button, it tries to make the library, and reports any errors or warnings. The problem is it doesn’t report warnings if the compile was successful.

I’m using the version of makeLibrary with a completion handler which passes in both a MTLLibrary? and Error? because the docs specifically say “Both library and error can be non-nil if the compiler successfully generates a library with warnings.” However I’m not seeing that happen, when there’s only warnings the Error parameter is nil.

Maybe I’m misunderstanding or using something wrong. Is this a bug or how do I get the warnings on a successful compile?

Here’s a demo. It should show 2 warnings but doesn’t because err is nil. Add an extraneous character in source to cause an error and then err is not nil and shows the 2 warnings.

import SwiftUI

let source = """
#include <metal_stdlib>
using namespace metal;

float something() {}

#warning "foo";

"""

struct ContentView: View {
    var body: some View {
        Button("test") {
        
            guard let device = MTLCreateSystemDefaultDevice() else { return }
            
            device.makeLibrary(source: source, options: nil) { lib, err in
                if err == nil {
                    print("no errors or warnings")
                } else if let err = err as? MTLLibraryError {
                    print("found errors or warnings")
                    print(err.localizedDescription)
                } else {
                    print("unknown error type")
                }
            }
            
        }
    }
}

Oh, and this is where it says both library and error can be non-nil https://developer.apple.com/documentation/metal/mtlnewlibrarycompletionhandler

makeLibrary doesn’t report warnings on successful compile
 
 
Q