I’m stumped… I have a new project (SPM based) that wraps a very complex cpp codebase. I’ve made a module that creates cpp wrappers around heavily templated code, and in turn I’m extending those wrapper types in swift. This all seemingly works great - but while writing test coverage I’ve started getting the following errors:
<unknown>:0: error: circular reference
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
<unknown>:0: error: circular reference
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
<unknown>:0: error: circular reference
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
<unknown>:0: error: circular reference
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
<unknown>:0: error: circular reference
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
<unknown>:0: error: circular reference
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
<unknown>:0: error: circular reference
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
<unknown>:0: error: circular reference
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
<unknown>:0: error: circular reference
<unknown>:0: note: through reference here
<unknown>:0: note: through reference here
I can’t find any annotations to where this error is, what here is, or what reference its referring to. I’ve commented out all the code in my tests and the error goes away. at this point I've removed almost all the code in the triggering test file. here’s what remains:
import Testing
@testable import HalideSwift
struct HalideMetalTests {
@Test func testCreateAndWrapMetalBuffer() {
let c = 255 * 255
}
}
commenting out the assignment line resolves the errors, but seemingly any additional code in this project triggers it again. how can I figure out where to even begin to look for the root cause of this issue?
The cycle appears to be just the last four lines. It looks like it's getting stuck in a loop looking up overloads of * inside the module HalideWrappers? Very weird.
It looks like a bug in the ClangImporter, because it’s looking up a conformance of a C++ type to Copyable, but that triggers a recursive name lookup. The request evaluator stops the infinite recursion and emits the diagnostic instead. Do you mind filing a bug? It would be nice if both the underlying issue was solved, and the diagnostic fixed to point to a source location in a synthesized buffer if a circular reference is diagnosed for some other reason in imported declarations.